Repository navigation
fix(storage): keep AsyncMultiRangeDownloader open after DataCorruption - #19170
Draft
zhixiangli wants to merge 1 commit into
Draft
zhixiangli wants to merge 1 commit into
zhixiangli wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request modifies the AsyncMultiRangeDownloader in the Google Cloud Storage asyncio package to keep the downloader stream open when a DataCorruption exception is raised, allowing callers to retry the range or close the stream manually. The docstrings, existing unit tests, and observability tests have been updated to reflect this change, and a new test has been added to verify that the downloader can be successfully reused after a data corruption event. There are no review comments to address, and I have no additional feedback to provide.
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.
Keep
AsyncMultiRangeDownloaderopen whendownload_ranges()raisesDataCorruption.Previously,
AsyncMultiRangeDownloader.download_ranges()caughtDataCorruptionand calledawait self.close(), closing the entire downloader (stream, multiplexer, and pool) on a single checksum or byte-count mismatch. Any subsequent or concurrentdownload_ranges()call on the same MRD instance then failed withValueError: Underlying bidi-gRPC stream is not open.Removing the
except DataCorruption:self-close block (while preservingfinally: strategy.discard_pending_checksums(initial_state)) scopes the failure to the affecteddownload_ranges()call so callers can retry the range or close the downloader explicitly.Changes
packages/google-cloud-storage/google/cloud/storage/asyncio/async_multi_range_downloader.py: remove theexcept DataCorruption:self.close()handler indownload_ranges(), and update the:raises DataCorruption:docstring to document that the downloader remains open.packages/google-cloud-storage/tests/unit/asyncio/test_async_multi_range_downloader.py: addtest_download_ranges_stays_open_on_datacorruptionandtest_download_ranges_after_datacorruption_reuses_mrd.packages/google-cloud-storage/tests/unit/asyncio/test_rapid_observability.py: updatetest_async_multi_range_downloader_data_corruption_marks_span_errorto assertmrd.is_stream_openremainsTrue(span assertions unchanged).Testing
pytest tests/unit/asyncio -k 'not (test_create_mrd_with_generation_number or test_unknown_read_id_is_dropped)': 425 passed, 2 deselected (the 2 deselected order-dependent caplog tests are pre-existing failures onupstream/main).ruff checkon touched files: passed.grpc.aioBidiReadObjectserver injecting a badcrc32cprior to rebase: afterDataCorruption,is_stream_openremainsTrueand subsequent + concurrent siblingdownload_ranges()calls reuse the open stream and return exact bytes.Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly: