fix(spanner): improve grpc-gcp affinity cleanup and location-aware retries#12682
Merged
fix(spanner): improve grpc-gcp affinity cleanup and location-aware retries#12682
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces a mechanism to unbind gRPC-GCP affinity keys after terminal RPCs (like Commit and Rollback) or when a specific channel hint is provided. It also adds logic to exclude endpoints that return RESOURCE_EXHAUSTED for the duration of a logical request's retry attempts. I have identified a discrepancy in the code comments within AbstractReadContext.java, where the comment claims the unbind flag is not carried on retries, despite the implementation explicitly adding it.
...spanner/google-cloud-spanner/src/main/java/com/google/cloud/spanner/AbstractReadContext.java
Outdated
Show resolved
Hide resolved
sakthivelmanii
approved these changes
Apr 6, 2026
6f4791b to
69fc961
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This change updates grpc-gcp channel-affinity behavior and location-aware retry behavior in the Java Spanner client.
It does three things:
RESOURCE_EXHAUSTEDdo not go back to the same routed endpoint for the same logical request.What Changed
grpc-gcp channel hints
When grpc-gcp is enabled:
writeAtLeastOnce) now uses a random channel hintexplicit affinity unbind
Added
UNBIND_CHANNEL_HINTsupport and wired it through grpc-gcp call options.This now:
location-aware retry behavior
For location-aware routing:
RESOURCE_EXHAUSTED, the next retry attempt for that same logical request avoids that endpointX-Goog-Spanner-Request-Idlogical request identity, so unrelated transactions/requests do not nherit the exclusion