Skip to content

Make multiupload/finish idempotent to prevent cascade of 500 errors on retry#49

Open
Goober5000 wants to merge 1 commit into
ngld:masterfrom
Goober5000:idempotent_multiupload_finish
Open

Make multiupload/finish idempotent to prevent cascade of 500 errors on retry#49
Goober5000 wants to merge 1 commit into
ngld:masterfrom
Goober5000:idempotent_multiupload_finish

Conversation

@Goober5000
Copy link
Copy Markdown
Collaborator

When a client calls multiupload/finish and the reverse proxy times out (504) before the response reaches the client, the client retries. Each retry would create a duplicate UploadedFile record (causing NotUniqueError) or fail reading already-deleted chunks (FileNotFoundError), both surfacing as 500 errors. This was observed in production as 17 rapid-fire 500s.

Check file.done at the top of finish_chunked_upload and return success immediately if the upload was already finalized, avoiding redundant reassembly and the resulting errors.

…n retry

When a client calls multiupload/finish and the reverse proxy times out
(504) before the response reaches the client, the client retries. Each
retry would create a duplicate UploadedFile record (causing NotUniqueError)
or fail reading already-deleted chunks (FileNotFoundError), both surfacing
as 500 errors. This was observed in production as 17 rapid-fire 500s.

Check file.done at the top of finish_chunked_upload and return success
immediately if the upload was already finalized, avoiding redundant
reassembly and the resulting errors.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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