fix(storage): consume server responses before finishing stream in AsyncWriter Close/Finalize - #16270
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.30% +0.01%
==========================================
Files 2221 2223 +2
Lines 207384 207876 +492
==========================================
+ Hits 191402 191883 +481
- Misses 15982 15993 +11 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
133bbd7 to
3abeed5
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request updates AsyncWriterConnectionImpl to correctly handle and consume multiple response messages from the server before receiving an EOF during close and query operations. It also improves thread safety by ensuring proper mutex locking when accessing shared state. The review comments correctly identify opportunities to avoid unnecessary copies of non-fundamental protobuf messages by moving them out of futures using std::move(f).get().
fa7d6c7 to
cd7915d
Compare
5131cee to
37a99f3
Compare
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.