fix: make CompleteMultipartUpload idempotent and add part-number support to GetObject/HeadObject#2054
Open
fix: make CompleteMultipartUpload idempotent and add part-number support to GetObject/HeadObject#2054
Conversation
703804a to
3b671ee
Compare
benmcclelland
requested changes
Apr 16, 2026
…ort to GetObject/HeadObject Closes #1064 Use the multipart ETag as the in-progress directory suffix instead of the static `.inprogress` marker so that concurrent CompleteMultipartUpload calls for the same upload ID are all treated as successful (idempotent) rather than racing, where only one succeeded and the rest returned NoSuchUpload. After finalizing the multipart upload, store an `mp-metadata` xattr on the assembled object that records the upload ID and cumulative byte offsets for each part. GetObject and HeadObject now use this metadata to serve individual part ranges via the `partNumber` query parameter, returning a successful response instead of returning NotImplemented. Add two new S3 error codes: - `ErrInvalidPartNumberRange` (416 RequestedRangeNotSatisfiable) — returned when the requested part number exceeds the number of parts in the upload. - `ErrRangeAndPartNumber` (400 BadRequest) — returned when both a Range header and a partNumber query parameter are specified on the same request.
3b671ee to
7ea38b6
Compare
benmcclelland
requested changes
Apr 17, 2026
Comment on lines
4485
to
+4487
| // using an os.File allows zero-copy sendfile via io.Copy(os.File, net.Conn) | ||
| var body io.ReadCloser = f | ||
| if startOffset != 0 || length != objSize { | ||
| rdr := io.NewSectionReader(f, startOffset, length) | ||
| body = &backend.FileSectionReadCloser{R: rdr, F: f} | ||
| } | ||
| rdr := io.NewSectionReader(f, startOffset, length) | ||
| body := &backend.FileSectionReadCloser{R: rdr, F: f} |
Member
There was a problem hiding this comment.
it looks like we lost the zero-copy sendfile case here for when a range is not requested. for this to work, we need to set body to f when we dont need the range reader.
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.
Closes #1064
Use the multipart ETag as the in-progress directory suffix instead of the static
.inprogressmarker so that concurrent CompleteMultipartUpload calls for the same upload ID are all treated as successful (idempotent) rather than racing, where only one succeeded and the rest returned NoSuchUpload.After finalizing the multipart upload, store an
mp-metadataxattr on the assembled object that records the upload ID and cumulative byte offsets for each part. GetObject and HeadObject now use this metadata to serve individual part ranges via thepartNumberquery parameter, returning a successful response instead of returning NotImplemented.Add two new S3 error codes:
ErrInvalidPartNumberRange(416 RequestedRangeNotSatisfiable) — returned when the requested part number exceeds the number of parts in the upload.ErrRangeAndPartNumber(400 BadRequest) — returned when both a Range header and a partNumber query parameter are specified on the same request.