Skip to content

chore(spanner): wire location-aware routing into unary RPCs - #6562

Open
olavloite wants to merge 1 commit into
googleapis:mainfrom
olavloite:spanner-location-router-unary-rpcs
Open

chore(spanner): wire location-aware routing into unary RPCs#6562
olavloite wants to merge 1 commit into
googleapis:mainfrom
olavloite:spanner-location-router-unary-rpcs

Conversation

@olavloite

Copy link
Copy Markdown
Contributor
  • Wire LocationRouter into unary database RPCs (begin_transaction, commit, rollback, execute_sql, execute_batch_dml, partition_read, partition_query).
  • Add routing key extraction for PartitionReadRequest and PartitionQueryRequest.
  • Track and enforce transaction server affinity for read-write transactions (including inline begin and commit/rollback lifecycle clearing).
  • Ingest inline CacheUpdate from unary responses (CommitResponse, Transaction, ResultSet, ExecuteBatchDmlResponse).

@olavloite
olavloite requested review from a team as code owners August 27, 2026 09:38
@product-auto-label product-auto-label Bot added the api: spanner Issues related to the Spanner API. label Aug 27, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request implements location-aware routing for unary database RPCs (such as commit, rollback, execute_sql, and begin_transaction) in the Spanner client. It refactors routing resolution using a unified RoutingContext and introduces pre-route and post-route hooks to manage transaction affinity. Additionally, comprehensive mock tests are added to verify routing behaviors. The feedback suggests removing a redundant check for an empty or all KeySet in extract_proto_read_key_set_routing_key, as this is already handled internally by extract_key_from_proto_key_set.

Comment thread src/spanner/src/routing/key_extractor.rs
@codecov

codecov Bot commented Aug 27, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.98785% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 96.53%. Comparing base (80b3370) to head (06f7279).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
src/spanner/src/database_client.rs 98.71% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6562      +/-   ##
==========================================
+ Coverage   96.51%   96.53%   +0.01%     
==========================================
  Files         304      304              
  Lines       87943    88397     +454     
==========================================
+ Hits        84875    85330     +455     
+ Misses       3068     3067       -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@olavloite
olavloite force-pushed the spanner-location-router-unary-rpcs branch from 9fdf5ba to 40e3c87 Compare August 27, 2026 14:35
@olavloite

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request implements location-aware routing for Spanner RPCs, including transaction affinity tracking for read-write transactions and support for partition read and query operations. It introduces pre-route and post-route hooks to the define_db_rpc macro to manage routing context and transaction affinity, along with comprehensive tests to verify the new logic. The reviewer suggested using the 'let Some(...) else' pattern in the pre_route methods to simplify early returns, which improves code readability and aligns with the repository's style guide.

Comment thread src/spanner/src/database_client.rs
Comment thread src/spanner/src/database_client.rs
Comment thread src/spanner/src/database_client.rs Outdated
- Wire `LocationRouter` into unary database RPCs (`begin_transaction`, `commit`, `rollback`, `execute_sql`, `execute_batch_dml`, `partition_read`, `partition_query`).
- Add routing key extraction for `PartitionReadRequest` and `PartitionQueryRequest`.
- Track and enforce transaction server affinity for read-write transactions (including inline begin and commit/rollback lifecycle clearing).
- Ingest inline `CacheUpdate` from unary responses (`CommitResponse`, `Transaction`, `ResultSet`, `ExecuteBatchDmlResponse`).
@olavloite
olavloite force-pushed the spanner-location-router-unary-rpcs branch from 40e3c87 to 06f7279 Compare August 27, 2026 15:14
@olavloite

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request implements location-aware routing and transaction affinity tracking for unary database RPCs (such as begin_transaction, commit, execute_sql, execute_batch_dml, rollback, partition_query, and partition_read) in the Spanner client. It refactors the RPC macro definitions to support pre-routing and post-routing hooks, introduces a structured RoutingContext to manage routing decisions, and adds comprehensive unit and mock integration tests to validate the routing logic and affinity lifecycle. I have no feedback to provide as there are no review comments to assess.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: spanner Issues related to the Spanner API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant