Skip to content

fix(cleanup): release generations whose multipart upload can't be aborted - #59

Merged
fengmk2 merged 2 commits into
fix/multipart-bounded-bufferfrom
fix/cleanup-completed-upload-abort
Nov 13, 2026
Merged

fengmk2 merged 2 commits into
fix/multipart-bounded-bufferfrom
fix/cleanup-completed-upload-abort

Conversation

@fengmk2

@fengmk2 fengmk2 commented Nov 13, 2026 •

Copy link
Copy Markdown
Member

Publication left the upload ID of a completed multipart upload (blobs over 5 MiB) on the generation. When the generation expired, cleanup aborted that upload before it deleted the R2 objects and the D1 row, all in one try. R2 does not check that a resumed upload still exists, and its docs say callers must handle errors when the upload no longer exists. If the abort rejects, the row stays in deleting with its charged bytes and is retried every 10 minutes forever. Enough such rows fill the deployment byte budget, which blocks stores in every namespace, and take over the 16-row cleanup batch.

  • Publication now clears upload_id when it completes the upload.
  • Cleanup continues past an abort error only when R2 reports that the upload no longer exists (NoSuchUpload, code 10024). Any other error, such as a transient internal error, keeps the generation, its charge, and its upload ID for the next cleanup run.

The second change also releases rows that were published before this fix and still carry an upload ID, if R2 answers 10024 for them.

🤖 Generated with Claude Code

…rted

Publication left the upload ID of a completed multipart upload on the
generation. When the generation expired, cleanup aborted that upload before it
deleted the objects and the row, in one try block. R2 does not promise that a
resumed upload still exists, so if the abort rejects, the row stays in
'deleting' with its charged bytes and is retried every 10 minutes forever.
Enough such rows fill the shared byte budget and the 16-row cleanup batch for
every namespace.

Clear the upload ID when publication completes the upload, and treat a failed
abort as non-fatal. The bucket lifecycle already aborts uploads left
incomplete after one day. The second change also releases rows that were
published before this fix.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@fengmk2
fengmk2 added this pull request to stack #62 November 13, 2026 05:31
@fengmk2
fengmk2 marked this pull request as ready for review November 13, 2026 06:13
Comment thread src/database.ts Resolved
Review feedback: the catch also hid transient R2 failures for uploads that
still hold parts. Cleanup then deleted the row and released its charge, so
new stores could reuse that quota while the parts still used storage, and the
upload ID needed for a retry was lost.

Continue only when R2 reports NoSuchUpload (10024). Any other abort error
keeps the generation, its charge, and its upload ID for the next cleanup run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@fengmk2
fengmk2 merged commit 6f536dc into main Nov 13, 2026
3 checks passed
@fengmk2
fengmk2 deleted the fix/cleanup-completed-upload-abort branch November 13, 2026 06:54
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.

1 participant