Repository navigation
Conversation
There was a problem hiding this comment.
Code Review
This pull request implements the Cancel method in ObjectDescriptorReader to support cancelling range reads, returning a cancelled status. It also adds comprehensive unit tests to verify cancellation behavior, destructor behavior, and handling of subsequent chunks after cancellation. The review feedback points out two style guide violations where auto is used for string literals (kData0 and kData1) in the tests, and recommends using explicit types instead.
ajayky-os
force-pushed
the
fix/storage-object-descriptor-reader-cancel
branch
from
December 4, 2026 08:03
fba846d to
8121f07
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #16758 +/- ##
=======================================
Coverage 92.95% 92.95%
=======================================
Files 2284 2284
Lines 234065 234118 +53
=======================================
+ Hits 217566 217617 +51
- Misses 16499 16501 +2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
ajayky-os
force-pushed
the
fix/storage-object-descriptor-reader-cancel
branch
from
December 4, 2026 09:13
8121f07 to
dd33bbb
Compare
ObjectDescriptorReader::Cancel() was previously a no-op, so destroying an AsyncReader while its parent ObjectDescriptor stays alive left the range active: - A pending Read() ended with std::future_error: Broken promise when ~AsyncReader() started its background Discard loop and called ReadRange::Read() a second time. - The background Discard loop kept reading and discarding chunks until EOF and retained the ReadRange indefinitely if no data arrived. - RangeForResume() continued replaying the cancelled range across stream resumes. Implement ObjectDescriptorReader::Cancel() by calling impl_->OnFinish(CancelledError(...)), which immediately completes any pending Read() with kCancelled, marks IsDone() true, returns std::nullopt from RangeForResume(), ignores subsequent OnRead() chunks, and lets ~AsyncReader()'s Discard loop terminate and release the ReadRange immediately. Because ObjectDescriptorReaderTracing inherits from ObjectDescriptorReader without overriding Cancel(), traced readers automatically inherit this fix.
ajayky-os
force-pushed
the
fix/storage-object-descriptor-reader-cancel
branch
from
December 4, 2026 10:05
dd33bbb to
5490e48
Compare
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.
Summary
ObjectDescriptorReader::Cancel()so cancelling or destroying anAsyncReaderbacked by an activeObjectDescriptorcleanly cancels itsReadRange.Problem
ObjectDescriptorReader::Cancel()was previously an empty no-op:AsyncReaderwhile aRead()was pending caused~AsyncReader()'sDiscardloop to callReadRange::Read()a second time, overwriting the parkedwait_promise and failing the caller's future withstd::future_error: Broken promise.AsyncReaderearly leftReadRangealive in the backgroundDiscardloop until stream completion and causedRangeForResume()to replay the cancelled range across stream reconnects.Cancel()directly onObjectDescriptorReaderand drainingRead()delivered the rest of the range followed byStatus{}(OK).Changes
google/cloud/storage/internal/async/object_descriptor_reader.cc: Callimpl_->OnFinish(google::cloud::internal::CancelledError("range read cancelled", GCP_ERROR_INFO()))inObjectDescriptorReader::Cancel().Read()withStatusCode::kCancelled.IsDone() == truesoObjectDescriptorImplremoves the range on cleanup andRangeForResume()returnsstd::nullopt.OnRead()chunks while letting~AsyncReader()'sDiscardloop drain synchronously and release theReadRange.ObjectDescriptorReaderTracinginheritsCancel()directly without overriding it.google/cloud/storage/internal/async/object_descriptor_reader_test.cc: Added 4 unit tests covering directCancel(),~AsyncReader()with a pendingRead(),~AsyncReader()releasingReadRange, and ignoring post-cancel chunks.Testing
//google/cloud/storage:internal_async_object_descriptor_reader_test— PASSED (5/5)//google/cloud/storage:async_reader_test— PASSED//google/cloud/storage:internal_async_object_descriptor_impl_test— PASSED