chore(spanner): wire location-aware routing into begin_transaction and commit - #6671
chore(spanner): wire location-aware routing into begin_transaction and commit#6671olavloite wants to merge 2 commits into
Conversation
…d commit Connect unary `BeginTransaction` and `Commit` RPCs to location-aware routing in `DatabaseClient`: - `pre_route_begin_transaction` / `post_route_begin_transaction`: Resolve route and attach covering `RoutingHint` when `mutation_key` is present. Bind transaction affinity to the resolved connection (or fallback default gateway for unkeyed begins) upon successful transaction creation. - `pre_route_commit` / `post_route_commit`: Prioritize registered transaction affinity while deriving mutation `RoutingHint` from `request.mutations`. Fall back to round-robin channel pooling when neither affinity nor a routing key exists. Clear affinity upon commit completion. - `Mutation::select_mutation_key_ref`: Add an O(1) fast path for single-mutation slices, operate on borrowed references, exclude unroutable `Delete` mutations (full-table deletes, empty key sets, or missing key sets), and extract `is_routable_non_insert` to keep selection logic flat and idiomatic.
There was a problem hiding this comment.
Code Review
This pull request refactors location-aware routing in the Spanner client to intercept unary BeginTransactionRequest and CommitRequest calls, resolving leader or affinity routing and attaching a RoutingHint when active. It introduces Mutation::select_mutation_key_ref to select routing keys by reference, avoiding unnecessary clones, and adds comprehensive unit tests covering various routing, affinity, and mutation selection scenarios. No review comments were provided, so there is no feedback to address.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6671 +/- ##
==========================================
+ Coverage 96.72% 96.75% +0.03%
==========================================
Files 313 313
Lines 101266 102368 +1102
==========================================
+ Hits 97948 99049 +1101
- Misses 3318 3319 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Connect unary
BeginTransactionandCommitRPCs to location-aware routing inDatabaseClient:pre_route_begin_transaction/post_route_begin_transaction: Resolve route and attach coveringRoutingHintwhenmutation_keyis present. Bind transaction affinity to the resolved connection (or fallback default gateway for unkeyed begins) upon successful transaction creation.pre_route_commit/post_route_commit: Prioritize registered transaction affinity while deriving mutationRoutingHintfromrequest.mutations. Fall back to round-robin channel pooling when neither affinity nor a routing key exists. Clear affinity upon commit completion.Mutation::select_mutation_key_ref: Add an O(1) fast path for single-mutation slices, operate on borrowed references, exclude unroutableDeletemutations (full-table deletes, empty key sets, or missing key sets), and extractis_routable_non_insertto keep selection logic flat and idiomatic.