fix(storage): consume server responses before finishing stream in AsyncWriter Close/Finalize#16270
fix(storage): consume server responses before finishing stream in AsyncWriter Close/Finalize#16270kalragauri wants to merge 3 commits into
Conversation
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.
6d2b7b3 to
cc63d2d
Compare
a90a56f to
28689f7
Compare
a721d96 to
85a4af4
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #16270 +/- ##
========================================
Coverage 92.29% 92.29%
========================================
Files 2221 2221
Lines 207372 207619 +247
========================================
+ Hits 191386 191629 +243
- Misses 15986 15990 +4 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.The PR also updates unit tests that mock the upload stream to expect the additional
Read()call (returning EOF) and adjust the sequencer expectations.