fix(spanner): ensure executeQueryAsync is non-blocking#12715
Open
fix(spanner): ensure executeQueryAsync is non-blocking#12715
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request implements lazy initialization for asynchronous result sets by wrapping internal read and query operations in a memoized supplier. This change ensures that methods like readAsync and executeQueryAsync are non-blocking, deferring the actual execution until the result set is accessed. New tests verify this behavior and ensure that transactions are only initiated once. A review comment suggests a minor refactor in the test code to handle result set state transitions more efficiently by avoiding redundant calls to tryNext().
...oogle-cloud-spanner/src/test/java/com/google/cloud/spanner/AsyncReadOnlyTransactionTest.java
Outdated
Show resolved
Hide resolved
When `executeQueryAsync(..)` was called for a read-only transaction, the method would execute a blocking `BeginTransaction` RPC for the first query. This change ensures that the `BeginTransaction` RPC instead is executed using the background executor thread pool.
84c2338 to
8974940
Compare
sakthivelmanii
approved these changes
Apr 8, 2026
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
executeQueryAsync(..)was called for a read-only transaction, the method would execute a blockingBeginTransactionRPC for the first query. This change ensures that theBeginTransactionRPC instead is executed using the background executor thread pool.