Skip to content

chore(spanner): implement cache updater for location-aware routing - #6271

Open
olavloite wants to merge 2 commits into
googleapis:mainfrom
olavloite:spanner-routing-cache-updater
Open

chore(spanner): implement cache updater for location-aware routing#6271
olavloite wants to merge 2 commits into
googleapis:mainfrom
olavloite:spanner-routing-cache-updater

Conversation

@olavloite

Copy link
Copy Markdown
Contributor

Implement CacheUpdater to coordinate between Spanner CacheUpdate wire messages and the client's in-memory routing table (KeyRangeCache) and connection pool (ConnectionCache).

@olavloite
olavloite requested review from a team as code owners August 3, 2026 18:18
@product-auto-label product-auto-label Bot added the api: spanner Issues related to the Spanner API. label Aug 3, 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 introduces the CacheUpdater module to handle location-aware routing cache updates by applying CacheUpdate payloads to the KeyRangeCache and pre-warming server connections in the ConnectionCache. The review feedback recommends using a safer, error-returning method like try_get instead of get to avoid potential panics when pre-warming connections, as well as logging errors instead of swallowing them. Additionally, it suggests replacing flaky tokio::task::yield_now() calls in unit tests with a robust polling mechanism with a timeout.

Comment thread src/spanner/src/routing/cache_updater.rs
Comment thread src/spanner/src/routing/cache_updater.rs Outdated
Implement `CacheUpdater` to coordinate between Spanner `CacheUpdate` wire messages and the client's
in-memory routing table (`KeyRangeCache`) and connection pool (`ConnectionCache`).
@olavloite
olavloite force-pushed the spanner-routing-cache-updater branch from 577889d to 3a3013d Compare August 4, 2026 17:32
@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 introduces the CacheUpdater module to the Spanner location-aware routing implementation. CacheUpdater coordinates the ingestion of CacheUpdate payloads, applying updates to the in-memory KeyRangeCache and asynchronously pre-warming server connections in the ConnectionCache using the Tokio runtime. A comprehensive suite of unit tests has been added to verify its behavior, including deduplication and generation updates. There are no review comments to address, and the implementation aligns with the repository's style guidelines.

@codecov

codecov Bot commented Aug 4, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 99.15014% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 96.26%. Comparing base (35b9590) to head (3a3013d).

Files with missing lines Patch % Lines
src/spanner/src/routing/cache_updater.rs 99.15% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6271      +/-   ##
==========================================
+ Coverage   96.24%   96.26%   +0.01%     
==========================================
  Files         280      281       +1     
  Lines       72146    72499     +353     
==========================================
+ Hits        69440    69790     +350     
- Misses       2706     2709       +3     

☔ 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.

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