Skip to content

fix(spanner): ensure executeQueryAsync is non-blocking#12715

Open
olavloite wants to merge 1 commit intomainfrom
spanner-non-blocking-execute-query-async
Open

fix(spanner): ensure executeQueryAsync is non-blocking#12715
olavloite wants to merge 1 commit intomainfrom
spanner-non-blocking-execute-query-async

Conversation

@olavloite
Copy link
Copy Markdown
Contributor

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.

@olavloite olavloite requested review from a team as code owners April 8, 2026 15:52
@olavloite olavloite requested a review from sakthivelmanii April 8, 2026 15:53
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

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 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().

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.
@olavloite olavloite force-pushed the spanner-non-blocking-execute-query-async branch from 84c2338 to 8974940 Compare April 8, 2026 16:02
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.

2 participants