Fix s3 transfer stats corruption when two transfers share (type, src, dest) - #10590
Open
Adityaj0 wants to merge 1 commit into
Open
Fix s3 transfer stats corruption when two transfers share (type, src, dest)#10590Adityaj0 wants to merge 1 commit into
Adityaj0 wants to merge 1 commit into
Conversation
… dest) ResultRecorder's ongoing-transfer bookkeeping (_ongoing_progress, _ongoing_total_sizes) was keyed only by (transfer_type, src, dest). Each s3transfer Future already carries a unique future.meta.transfer_id, but it was dropped when building the Result namedtuples, so two concurrent transfers sharing the same key would collide: one's completion pops the shared dict entry, silently corrupting the other's progress/expected-size accounting (e.g. bytes_failed_to_transfer reporting 0 for a transfer that actually failed with bytes outstanding). Add an optional transfer_id field (default None, backward compatible) to the BaseResult-derived result types, populate it from future.meta.transfer_id in BaseResultSubscriber, and use it to disambiguate _get_ongoing_dict_key so transfers can never collide. Fixes aws#10589
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
Fixes #10589.
ResultRecorder's in-flight transfer bookkeeping (_ongoing_progress,_ongoing_total_sizes) is keyed only by(transfer_type, src, dest). Every s3transferFuturealready carries a uniquefuture.meta.transfer_id, but it's dropped before reachingResultRecorder. If two transfers are ever queued concurrently with the identical(transfer_type, src, dest)tuple, their bookkeeping collides in the same dict slot: whichever completes first pops the shared entry, corrupting the other's still-in-flight accounting (e.g.bytes_failed_to_transfercan read0for a transfer that genuinely failed with bytes outstanding).I was not able to construct a confirmed realistic end-to-end CLI scenario that triggers this (normal
cp/syncproduce unique(src, dest)per file), so I'm not claiming a proven high-severity data-loss path — see the honesty note in the linked issue. This is a real defect in the stats/progress accounting layer worth fixing defensively, since the disambiguating identifier is already available and simply unused.Fix
transfer_idfield (defaultNone) to theBaseResult-derived result types — fully backward compatible with all existing construction call sites.future.meta.transfer_idinBaseResultSubscriber._add_to_result_kwargs_cache._get_ongoing_dict_key(when present) to disambiguate otherwise-identical concurrent transfers.Test plan
test_concurrent_transfers_with_same_key_do_not_clobber_each_othertotests/unit/customizations/s3/test_results.py, reproducing the exact collision/clobbering scenario.tests/unit/customizations/s3/+tests/functional/s3/: 764 passed, 14 skipped, no regressions (up from 763 passed pre-change, reflecting the one new test)..changes/next-release/.🤖 Generated with Claude Code