Skip to content

Conversation

@michaelherold
Copy link
Contributor

This change makes it so queries against single-use transactions do not route to the leader, even when leader-aware routing is enabled, as these single-use transactions are read-only transactions with specific staleness requirements.

Checklist

Closes #196

This change makes it so queries against single-use transactions do not
route to the leader, even when leader-aware routing is enabled, as these
single-use transactions are read-only transactions with specific
staleness requirements.
@michaelherold michaelherold requested review from a team as code owners November 3, 2025 18:04
gapic_options.metadata["x-goog-spanner-route-to-leader"] == 'true'
end
mock.expect :execute_streaming_sql, results_enum do |request, gapic_options|
gapic_options.metadata["x-goog-spanner-route-to-leader"] == 'false'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

question: I'm unsure if "false" here or not emitting it would be better, but the helper specifies "false" so that's what I went with.

@michaelherold michaelherold changed the title bug: Don't route to leader for single use txns Don't route to leader for single-use transactions Nov 3, 2025
tag_type: :request_tag
single_use_tx = single_use_transaction single_use
route_to_leader = LARHeaders.execute_query true
route_to_leader = LARHeaders.execute_query !single_use_tx

Choose a reason for hiding this comment

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

I am pretty sure it should be just false. If it's single-use (as specified by the caller) it's RO explicitly; if nil is specified by the caller, the default case for execute_streaming_sql is a "temporary read-only transaction with strong concurrency" https://github.com/googleapis/googleapis/blob/53af3b727f84acc34e31c23f3b6e7b8aa4b7e837/google/spanner/v1/spanner.proto#L716-L717

@viacheslav-rostovtsev
Copy link
Member

obsolete by #201

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Client#execute_query always routes to leader, even when unnecessary

2 participants