fix(spanner): prevent deadlock if ResultSet#next() is never called (step 5)#5654
Merged
olavloite merged 6 commits intoMay 13, 2026
Merged
Conversation
…tep 5) If a query included a BeginTransaction option and the application never called ResultSet#next(), then the transaction ID would never be returned. This would block any other query from using the transaction. This change refactors ResultSet to use a background worker to read from the stream. This prevents that a deadlock can happen if the application does not call ResultSet#next(). It also allows the application to call ResultSet#metadata() without first calling ResultSet#next(). Finally, it also allows the ResultSet to decode data from the server asynchronously while the application processes rows that it has already read from the ResultSet. Replaces googleapis#5324 due to too massive merge conflicts.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5654 +/- ##
==========================================
- Coverage 97.92% 97.92% -0.01%
==========================================
Files 221 222 +1
Lines 52759 53183 +424
==========================================
+ Hits 51663 52077 +414
- Misses 1096 1106 +10 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Code Review
This pull request refactors ResultSet to utilize a background worker task for stream processing, making ResultSet::metadata asynchronous and fixing a potential deadlock in lazy transaction starts. Review feedback identifies that ResultSet is no longer Sync due to the new mpsc::Receiver field, which may break existing code, and notes a style guide violation concerning the use of unwrap() in production logic.
sakthivelmanii
approved these changes
May 13, 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.
If a query included a BeginTransaction option and the application never called ResultSet#next(), then the transaction ID would never be returned. This would block any other query from using the transaction. This change refactors ResultSet to use a background worker to read from the stream. This prevents that a deadlock can happen if the application does not call ResultSet#next(). It also allows the application to call ResultSet#metadata() without first calling ResultSet#next(). Finally, it also allows the ResultSet to decode data from the server asynchronously while the application processes rows that it has already read from the ResultSet.
Replaces #5324 due to too massive merge conflicts.