Skip to content

fix(ObjectStore): reset multipart upload byte counter on retry - #62919

Merged
CarlSchwan merged 1 commit into
nextcloud:masterfrom
ching-kuo:fix/s3-multipart-retry-byte-count
Aug 6, 2026
Merged

fix(ObjectStore): reset multipart upload byte counter on retry#62919
CarlSchwan merged 1 commit into
nextcloud:masterfrom
ching-kuo:fix/s3-multipart-retry-byte-count

Conversation

@ching-kuo

Copy link
Copy Markdown
Contributor

Summary

writeMultiPart() initializes $totalWritten once outside the retry loop, so bytes from a failed first attempt accumulate into the second attempt. Since $state is never resumed, each retry rewinds the stream and re-uploads the whole object from scratch, making before_complete compare roughly twice the object size against the expected size. The retry then always fails with "Incomplete multi part upload, expected X bytes, wrote 2X" and the upload is aborted.

Reset the counter per attempt so the size check validates only the bytes written by the current attempt.

TODO

N/A

Checklist

AI (if applicable)

  • The content of this PR was partly or fully generated using AI

writeMultiPart() initializes $totalWritten once outside the retry loop,
so bytes from a failed first attempt accumulate into the second attempt.
Since $state is never resumed, each retry rewinds the stream and
re-uploads the whole object from scratch, making before_complete compare
roughly twice the object size against the expected size. The retry then
always fails with "Incomplete multi part upload, expected X bytes,
wrote 2X" and the upload is aborted.

Reset the counter per attempt so the size check validates only the
bytes written by the current attempt.

Fixes nextcloud#59505

Signed-off-by: Ching Kuo <igene@igene.tw>
Assisted-by: Claude Code:claude-fable-5
@ching-kuo
ching-kuo requested a review from a team as a code owner August 5, 2026 03:26
@ching-kuo
ching-kuo requested review from Altahrim, nfebe, provokateurin and salmart-dev and removed request for a team August 5, 2026 03:26
@ching-kuo
ching-kuo force-pushed the fix/s3-multipart-retry-byte-count branch from c0e7b6b to db36014 Compare August 5, 2026 03:27
@CarlSchwan

Copy link
Copy Markdown
Member

/backport to stable33

@CarlSchwan

Copy link
Copy Markdown
Member

/backport to stable34

@CarlSchwan CarlSchwan added bug 3. to review Waiting for reviews labels Aug 5, 2026
@CarlSchwan
CarlSchwan enabled auto-merge August 5, 2026 17:07
@ching-kuo

Copy link
Copy Markdown
Contributor Author

Looks like the required failing tests all unrelated to the changes. Any ways to trigger a rerun of the tests?

@CarlSchwan
CarlSchwan merged commit ec796fd into nextcloud:master Aug 6, 2026
285 of 300 checks passed
@welcome

welcome Bot commented Aug 6, 2026

Copy link
Copy Markdown

Thanks for your first pull request and welcome to the community! Feel free to keep them coming! If you are looking for issues to tackle then have a look at this selection: https://github.com/nextcloud/server/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22

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

Labels

3. to review Waiting for reviews bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: S3 Multipart Retry counts bytes across attempts causing fails upload

4 participants