feat(spanner): implement transaction routing logic based on database metadata isolation levels and lock modes#13800
Open
shobhitsg wants to merge 1 commit into
Open
feat(spanner): implement transaction routing logic based on database metadata isolation levels and lock modes#13800shobhitsg wants to merge 1 commit into
shobhitsg wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces dynamic database-level metadata detection (dialect, default transaction isolation level, and default read lock mode) queried from INFORMATION_SCHEMA.DATABASE_OPTIONS to replace client-side hardcoded defaults. The feedback identifies several critical issues: a correctness bug in canEnableLRYW that breaks Leader-Routed Read-Your-Writes for repeatable read transactions with unspecified lock modes, a race condition in metadataSupplier when retrieving the session reference, and a concurrency race condition in AbstractLazyInitializer between reset() and get(). Additionally, it is recommended to add a unit test to prevent regressions for repeatable reads with null lock modes.
shobhitsg
force-pushed
the
lryw_client
branch
4 times, most recently
from
July 20, 2026 06:54
374c33b to
9b23481
Compare
shobhitsg
marked this pull request as ready for review
July 20, 2026 09:37
shobhitsg
force-pushed
the
lryw_client
branch
3 times, most recently
from
July 20, 2026 17:54
228b637 to
d7c22d3
Compare
…metadata isolation levels and lock modes
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.
When a multiplexed session is created or replaced, the client library now automatically executes an asynchronous gRPC query (
SELECT ... FROM INFORMATION_SCHEMA.DATABASE_OPTIONS) to cache database isolation levels and default read lock modes for Local Read-Your-Writes (LRYW) routing. Because this query executes via the standard query pipeline (singleUse().executeQuery(...)), it emits normal telemetry:Tests that strictly assert exact RPC invocation counts, channel allocations, and OpenTelemetry/OpenCensus span arrays (particularly under Java 8 where reflection-heavy tracer tests run) required updates to account for this automated warmup query.
Alternative Approaches
disableMetadataIntrospection)SessionPoolOptionsor a system property switch to suppress the metadata query during unit tests so test files wouldn't need updating one by one.@Before setUp()setUp()and callspanExporter.reset()right before individual test methods execute to erase startup query spans.SpanTestandOpenTelemetrySpanTestexplicitly assert that the test's initial transaction generates theCreateMultiplexedSessionspan and annotation. Erasing spans in setup destroyed this required session-creation span, breaking assertions.