chore(spanner): add stream lifetime guards and error tracking to server streaming - #6735
chore(spanner): add stream lifetime guards and error tracking to server streaming#6735olavloite wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors the stream lifetime management by introducing a StreamGuard trait and updating StreamLifetimeGuard to be an Arc<dyn StreamGuard>. This enables recording RPC error codes during stream failures or initial handshakes across various Spanner operations. The review feedback suggests two minor code simplifications: directly pattern matching on self.lifetime_guard.take() in next_message to avoid a temporary variable, and directly assigning lifetime_guard to the stream in make_server_streaming_request instead of using an if let block.
0c9131e to
0f156fb
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request refactors stream lifetime management by introducing a StreamGuard trait and updating StreamLifetimeGuard to be an Arc<dyn StreamGuard>. This allows recording RPC error codes during stream lifetime events (initial handshake failures and stream errors) to support dynamic channel pooling. The builder classes and streaming requests are updated to propagate this guard, and comprehensive tests are added. The review feedback recommends refactoring the tuple pattern matching in SpannerServerStream::next_message and make_server_streaming_request into nested if let statements to avoid implicit side-effects and improve code readability in alignment with the 'Reject Code Poetry' style guide principle.
0f156fb to
aadff1a
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request refactors the server streaming lifetime management in the Spanner client. It replaces the opaque Box<dyn Any + Send + Sync> lifetime guard with a structured StreamLifetimeGuard (an Arc) capable of recording RPC error codes. This enables tracking connection issues for dynamic channel pooling. The streaming builders (ExecuteStreamingSql, StreamingRead, BatchWrite, and FetchCacheUpdate) now support attaching this guard, and both initial handshake failures and stream errors are updated to record their status codes. I have no feedback to provide as there are no review comments.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6735 +/- ##
========================================
Coverage 96.96% 96.97%
========================================
Files 319 319
Lines 105574 105844 +270
========================================
+ Hits 102365 102637 +272
+ Misses 3209 3207 -2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
aadff1a to
05e4899
Compare
Adds RAII lifetime guards and error reporting to Spanner server-streaming RPCs.
This allows streaming operations (such as
ExecuteStreamingSqlandStreamingRead) to hold an opaque guard that tracks in-flight RPC state on the underlying channel lease for the full lifetime of the stream. If a stream fails during the initial handshake or mid-stream, the error status code is recorded on the guard so the channel pool can update channel health metrics and error penalties.