Skip to content

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

Open
ching-kuo wants to merge 1 commit into
nextcloud:masterfrom
ching-kuo:fix/s3-multipart-retry-byte-count
Open

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

Conversation

@ching-kuo

Copy link
Copy Markdown

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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