Skip to content

Conversation

@shubham-up-47
Copy link
Contributor

@shubham-up-47 shubham-up-47 commented Sep 29, 2025

This PR refactors AsyncWriterConnectionBuffered to fix critical bugs in its resume and finalization logic, which were discovered while updating integration tests where a final Flush was not happening during finalization, that time a temporary fix was done. These changes are totally inspired by the PR #15114 making the component significantly more reliable.

The original implementation was just calling Write() during Flush() and contained subtle flaws in its state machine when handling a Finalize() failure. This could lead to incorrect state transitions during a resume, or deadlocks where pending Flush calls would hang indefinitely during race conditions with SetFinalized. The fix introduces a distinct implementation for Flush() with its own promise queue to ensure a reliable completion signal. To correct the resume behavior, OnFinalize is modified to preserve the finalizing_ state, and OnResume is updated to use the new connection immediately, preventing incorrect retries. The idempotency guard in SetFinalized now correctly drains the flush queue to prevent hangs.

This change is Reviewable

@shubham-up-47 shubham-up-47 requested review from a team as code owners September 29, 2025 13:01
@product-auto-label product-auto-label bot added the api: storage Issues related to the Cloud Storage API. label Sep 29, 2025
@shubham-up-47 shubham-up-47 marked this pull request as draft September 29, 2025 13:01
@shubham-up-47 shubham-up-47 marked this pull request as ready for review October 6, 2025 20:36
@codecov
Copy link

codecov bot commented Oct 6, 2025

Codecov Report

❌ Patch coverage is 99.51456% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.10%. Comparing base (859f506) to head (8eecba2).
⚠️ Report is 14 commits behind head on main.

Files with missing lines Patch % Lines
...le/cloud/storage/examples/storage_async_samples.cc 0.00% 3 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##             main   #15572    +/-   ##
========================================
  Coverage   93.09%   93.10%            
========================================
  Files        2418     2418            
  Lines      221886   222282   +396     
========================================
+ Hits       206569   206949   +380     
- Misses      15317    15333    +16     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

v-pratap
v-pratap previously approved these changes Oct 8, 2025
scotthart
scotthart previously approved these changes Oct 8, 2025
@shubham-up-47 shubham-up-47 merged commit 60befd1 into googleapis:main Oct 9, 2025
69 of 72 checks passed
@shubham-up-47 shubham-up-47 deleted the fixing_buffered_upload branch October 9, 2025 06:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: storage Issues related to the Cloud Storage API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants