Repository navigation
Support copying an empty object on S3-compatible storages that reject a zero-size CopyObject - #129316
Conversation
A whole-object CopyObject rejected with InvalidArgument, InvalidRequest, EntityTooLarge (or the GCS rewrite error) is retried as a multipart upload copy whenever the client supports multipart copy, regardless of the object size. For an empty object UploadHelper::calculatePartSize rejects size 0 with LOGICAL_ERROR "Chosen multipart upload for an empty file. This must not happen", which aborts debug builds and servers with abort_on_logical_error. It is reached on endpoints that reject a zero-size CopyObject (RustFS), e.g. when a plain_rewritable S3 disk unlinks an empty file, because the unlink copies the blob first (STID 0250-04e2 in the CI of ClickHouse#113825). An empty object now takes the existing regular-upload fallback, as it does for AccessDenied or without multipart copy support: a single-part PutObject of an empty body, so the copy completes. The same precondition was violated one step further: a zero-size PutObject rejected with EntityTooLarge / InvalidRequest also fell back to a multipart upload. A multipart upload cannot write an empty object either, so the endpoint's own error is reported instead. The guard in calculatePartSize stays as the invariant; the callers were wrong. Closes ClickHouse#129218 Co-Authored-By: Claude Opus 5.5 <[email protected]>
The multipart retry of a rejected whole-object CopyObject is an UploadPartCopy, which always sends a byte range. It now requires what the copy routing already requires: multipart copy allowed (s3_allow_multipart_copy) and a source larger than the 5 MB byte-range minimum S3 accepts. Every other case, an empty object included, takes the existing regular-upload fallback. Before, the retry ignored s3_allow_multipart_copy, and for a source of 5 MB or less it issued a byte-range copy that S3 rejects with InvalidRequest. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Shorten the comment on the rejected-CopyObject fallback condition to one line; the 5 MB rule is documented at MIN_SOURCE_SIZE_FOR_RANGE_COPY. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Internal second-model review (click to expand)
The second review round on the fix returned no findings. |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-4:20261104-141900 |
|
cc @CheSema @alesapin, could you review this and add the |
|
Workflow [PR], commit [6cc74a3] Summary: ✅
AI ReviewSummaryThe change prevents a rejected empty-object Missing context / blind spots
Final VerdictStatus: ✅ Approve. No code changes requested; normal CI validation remains pending. |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units7 translation units recompiled, 11 s compile time in total, 7 of them have a recent master baseline. |
copyS3File of an empty object when the endpoint rejects CopyObjectCopyObject
3f4c574
Closes: #129218
Related: #113825
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Better compatibility with S3-compatible storages that reject
CopyObjectof an empty object (for example, RustFS): copying an empty object, such as removing an empty file from aplain_rewritabledisk, now falls back to a regular upload. A rejectedCopyObjectis retried as a multipart copy only when multipart copy is allowed (s3_allow_multipart_copy) and the source is larger than 5 MB. Closes #129218.Description
MinIO and AWS accept a
CopyObjectof an empty object, but some S3-compatible storages reject it withInvalidArgument,InvalidRequestorEntityTooLarge(RustFS does). There, copying an empty object fails withLOGICAL_ERRORChosen multipart upload for an empty file. This must not happeninstead of completing; debug builds and servers withabort_on_logical_errorabort. Aplain_rewritableS3 disk reaches it when it unlinks an empty file, because the unlink copies the blob first. Real failing job: STID0250-04e2in the RustFS CI experiment #113825 (report).CopyFileHelper::processCopyRequestretries a rejected whole-object copy as a multipart upload copy without looking at the size, andUploadHelper::calculatePartSizerejects size 0 on purpose. One step further,CopyDataToFileHelper::processPutRequestdid the same for a rejected zero-sizePutObject(EntityTooLarge/InvalidRequest).Change:
UploadPartCopy, which always sends a byte range) now requires what the routing already requires: multipart copy allowed and a source above the 5 MB byte-range minimum. Every other case, an empty object included, takes the existing regular-upload fallback, asAccessDeniedalready does, so the copy completes.PutObjectreports the endpoint's own error, since nothing else can write an empty object.The guard in
calculatePartSizeis unchanged.Validation: four new
CopyS3FileRoutingTestgtest cases (empty, small, disableds3_allow_multipart_copywith a positive control, rejected emptyPutObject), with aCopyObjectrejection hook in the mock client (MinIO and AWS accept such a copy, so a stateless test cannot reach the fallback). Without the fix the empty-object cases abort with thisLOGICAL_ERRORand the others fail; reverting any single term reddens its case; with the fix all pass, 50/50.Workflow [PR]
Sync PR [sync-upstream/pr/129316]
Version info
26.11.1.1499-master(included in26.11and later)