fix(storage): consume server responses before finishing stream in AsyncWriter Close/Finalize#16270
Open
kalragauri wants to merge 3 commits into
Open
fix(storage): consume server responses before finishing stream in AsyncWriter Close/Finalize#16270kalragauri wants to merge 3 commits into
kalragauri wants to merge 3 commits into
Conversation
…ncWriter Close/Finalize
There was a problem hiding this comment.
Code Review
This pull request refactors OnClose and OnFinalUpload in AsyncWriterConnectionImpl to use a recursive ConsumeLoop that reads and processes all intermediate server responses before finalizing the upload, preventing hangs when multiple responses are sent before EOF. Corresponding unit tests are updated and a new test is added to verify this behavior. The review feedback correctly identifies compilation errors in both refactored methods where the undefined variable self is referenced inside lambdas capturing [this], and provides code suggestions to resolve these issues by calling Finish() directly.
kalragauri
force-pushed
the
feat/close-hangs
branch
4 times, most recently
from
July 21, 2026 10:00
6d2b7b3 to
cc63d2d
Compare
kalragauri
marked this pull request as ready for review
July 21, 2026 10:22
kalragauri
force-pushed
the
feat/close-hangs
branch
from
July 22, 2026 12:47
824612c to
66f216b
Compare
kalragauri
force-pushed
the
feat/close-hangs
branch
from
July 22, 2026 12:51
a90a56f to
28689f7
Compare
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.
This PR fixes an issue where calling
AsyncWriter::Close()orFinalize()hangs indefinitely when the GCS service returns intermediate response messages before closing the stream.Under the hood, Close() sends a
kFlushAndCloserequest, which prompts GCS to respond. Previously,AsyncWriterConnectionImplcalled Finish() on the underlying gRPC stream immediately after writing without consuming any remaining server responses. This unread data on the stream causedFinish()to block waiting for response consumption, leading to a deadlock.