chore(spanner): record transaction affinity for streaming RPCs with inline begin - #6731
chore(spanner): record transaction affinity for streaming RPCs with inline begin#6731olavloite wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Code Review
This pull request implements transaction affinity routing for Spanner server-streaming RPCs (ExecuteStreamingSql and StreamingRead) by introducing a callback mechanism to capture the first transaction ID returned in a stream. It also adds comprehensive integration and unit tests to verify affinity recording, error handling, aborted retries, and tablet routing. The review feedback suggests refactoring several conditional builder configurations to use idiomatic Rust expressions instead of mutable variables.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6731 +/- ##
========================================
Coverage 96.80% 96.81%
========================================
Files 313 313
Lines 104285 104513 +228
========================================
+ Hits 100958 101188 +230
+ Misses 3327 3325 -2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…nline begin When executing a streaming query (execute_streaming_sql) or streaming read (streaming_read) with an inline-begin read-write transaction in Spanner Omni, the returned transaction ID was not being captured to establish location-aware routing affinity. This change: - Captures the transaction ID from the first stream response chunk and registers node affinity with the location router. - Introduces a single-use TransactionIdCallback (Box<dyn FnOnce>) attached during stream construction. - Adds helper logic on DatabaseClient to determine whether affinity recording is required based on the transaction selector and routing mode. - Expands mock tests covering inline-begin streaming queries, streaming reads, stream errors, and aborted transaction retries.
44e237f to
ffc8d98
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request implements transaction affinity recording for streaming RPCs (such as streaming SQL and streaming reads) that initiate inline read-write transactions. It introduces a TransactionIdCallback mechanism to extract the transaction ID from the first PartialResultSet in the stream and record affinity to the target server address. Additionally, comprehensive unit and mock integration tests have been added to verify this behavior across various scenarios, including multi-chunk streams, aborted transaction retries, and tablet routing. I have no feedback to provide as there are no review comments to evaluate.
When executing a streaming query (execute_streaming_sql) or streaming read (streaming_read) with an inline-begin read-write transaction in Spanner Omni, the returned transaction ID was not being captured to establish location-aware routing affinity.
This change: