Keep resumed S3 copy parts within the backend size limit

perfloop-oss/distribution · Uncatalogued correctness

https://perfloop.ai/t/oss/case_amwkjs9f03

Verdict

VERIFIED · settled 2026-11-16 · pull request opened as distribution/distribution#5090

What happened: The check fails before this change and passes with it.

Hypothesis

Resuming an S3 upload with a small final part copies the entire saved file into one replacement part. Large, otherwise valid upload histories can therefore produce an oversized copy request. A bounded native check reproduces this against a local service model; live S3 behavior and trigger frequency remain unmeasured.

In writer.Write, the replacement path requires an existing final part smaller than minChunkSize. After completion and replacement creation succeed, a saved total of at least minChunkSize takes the UploadPartCopyWithContext branch. That request has no CopySourceRange and uses part number 1, so its requested part extent is the whole saved object, not one configured chunk. Early completion or creation failures do not reach this copy. The smaller-than-minChunkSize download branch is not implicated.

The new package-native file registry/storage/driver/s3-aws/hunt_writer_properties_test.go contains TestHuntS3CopyLimit. It enumerates exactly three persisted metadata fixtures: 5 GiB minus one byte, 5 GiB, and 5 GiB plus one byte. Each has at most 854 parts, consisting of full 6 MiB parts and a final part below 5 MiB. The fixture does not stream or allocate a 5 GiB payload. It runs the real driver and SDK through the existing HTTP-client seam and enforces a 5 GiB maximum part size. In bash call_iGfoehejRfKu56H0xcjh45qK, the first two fixtures passed. The reduced command `go test -count=1 -v -run '^TestHuntS3CopyLimit$/^5368709121$' ./registry/storage/driver/s3-aws` exited 1 with `supported resume size=5368709121: n=0 err=EntityTooLarge: fixture boundary` and `requested copy sizes=[5368709121] ranges=[""]`. This is request-construction evidence under the explicit model, not a remote-service measurement.

The broader local-staging redesign is already prior repair hyp_6tvyc906t8. Prior repair hyp_dq9f786s1f instead removes the final content-addressed Move copy, not this intermediate resume copy. Current upstream https://github.com/distribution/distribution/pull/4717 moves reassembly out of Write but retains the same single, unranged UploadPartCopy. The SDK migration at https://github.com/distribution/distribution/pull/4952 also retains it. Neither implements bounded replay copies. CONTRIBUTING.md specifies GitHub PR review. Open pages were followed to their end; recent merged-file history remains a named gap because the checkout is shallow and the bounded history API request was refused.

The smallest useful Case check is to verify the service part limit and rerun the reduced metadata witness, then establish that replay ranges conserve the exact prefix without creating an over-limit part. Modest byte-backed fixtures can check ordering and content. This test layout is provisional. No speedup, production blob-size distribution, or production-only prevalence gate is asserted.

Change to test: Keep every replacement copy part within the backend’s supported extent while preserving the complete saved prefix and valid part numbering. Bounded range copies are a provisional implementation; retain the small-prefix replay branch and existing configuration behavior.

Where it lives

perfloop-oss/distribution · registry/storage/driver/s3-aws/s3.go

Evidence

The check fails before this change and passes with it: `Under the metadata-only S3 model in TestWriterResumeCopy, each tested saved upload ending in a part below 5 MiB resumes using ordered copy parts between 5 MiB and 5 GiB that cover its saved prefix exactly once; subsequent writes append under successive part numbers in 1..10000 and commit successfully.`

Checks: 4 of 4 passed. Verification: no defect found.

Timeline