Skip to content

fix: make CompleteMultipartUpload idempotent and add part-number support to GetObject/HeadObject#2054

Open
niksis02 wants to merge 1 commit intomainfrom
sis/racing-complete-mp
Open

fix: make CompleteMultipartUpload idempotent and add part-number support to GetObject/HeadObject#2054
niksis02 wants to merge 1 commit intomainfrom
sis/racing-complete-mp

Conversation

@niksis02
Copy link
Copy Markdown
Contributor

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.

@niksis02 niksis02 force-pushed the sis/racing-complete-mp branch 2 times, most recently from 703804a to 3b671ee Compare April 16, 2026 19:41
Comment thread backend/posix/posix.go
Comment thread backend/azure/azure.go
Comment thread backend/azure/azure.go Outdated
Comment thread backend/common.go Outdated
Comment thread backend/posix/posix.go
Comment thread tests/integration/utils.go Outdated
Comment thread backend/posix/posix.go Outdated
…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.
@niksis02 niksis02 force-pushed the sis/racing-complete-mp branch from 3b671ee to 7ea38b6 Compare April 17, 2026 18:41
@niksis02 niksis02 requested a review from benmcclelland April 17, 2026 18:56
Comment thread backend/posix/posix.go
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}
Copy link
Copy Markdown
Member

@benmcclelland benmcclelland Apr 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] - return success for successive complete multipart upload calls

2 participants