Repository navigation
Conversation
Previously, streaming reads and queries buffered incoming chunks without a limit while waiting for a resume token from Spanner. If a stream sent many chunks without a resume token, memory usage could grow unboundedly and row delivery to the caller would stall. With this change: - Streaming results now buffer at most 512 chunks while waiting for a resume token. - Once that limit is exceeded, buffered chunks are flushed immediately to the caller and retries are disabled so already-yielded rows cannot be duplicated. - Subsequent chunks without a resume token continue streaming directly without buffering, and any transient stream failure is propagated immediately instead of being retried. - Retries are re-enabled only if a newer resume token arrives later in the stream. - Both the synchronous and asynchronous clients are updated consistently, with unit and mock-server tests covering the threshold, failure, and recovery paths.
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces a buffer limit (_MAX_BUFFERED_CHUNKS = 512) for PartialResultSet chunks in both synchronous and asynchronous snapshot implementations to prevent unbounded buffering when waiting for a resume_token. If the limit is exceeded, the chunks are flushed downstream and retries are disabled until a newer resume_token is received. Comprehensive unit and mock server tests are added to validate this behavior. The review feedback suggests adding an explanatory comment in the synchronous implementation to match the asynchronous one for consistency, and removing redundant parentheses in a generator expression to comply with PEP 8.
This branch has not been deployed
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.
Previously, streaming reads and queries buffered incoming chunks without a limit while waiting for a resume token from Spanner. If a stream sent many chunks without a resume token, memory usage could grow unboundedly and row delivery to the caller would stall.
With this change: