Repository navigation
fix: hold upload lock during stream interruption until data is persisted - #136
Merged
Merged
Conversation
- Do not prematurely release the upload lock inside InterruptibleInputStream.interrupt(). - Retain the lock throughout stream interruption so that in-flight buffered bytes are flushed and persisted to storage and UploadInfo metadata is updated before resuming requests acquire the lock. - Clean up unreleased uploadLock references from InterruptibleInputStream and TusServletRequest. - Add multi-backend integration test verifying interrupted uploads persist bytes before HEAD responds. - Add ASYNC_REVIEW.md to .gitignore.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When an in-progress upload is interrupted (for example, upon upload pause followed immediately by a resume
HEADrequest), the uploading thread must hold its exclusive upload lock while sending and persisting buffered in-flight bytes to storage and updatingUploadInfometadata.Previously,
InterruptibleInputStream.interrupt()released the lock prematurely before the upload thread finished persisting buffered bytes to the underlying storage backend. When a resumeHEADrequest arrived within the same second, it acquired the lock and read staleUploadInfobefore the upload thread could flush/commit its buffered data, causing data loss and progress rollbacks.Changes
InterruptibleInputStream.interrupt(). The lock remains held by the uploading thread until its write operation finishes persisting buffered bytes and updatingUploadInfometadata, releasing the lock in the standard try-finally block inTusFileUploadService.process().uploadLockreferences and accessors fromInterruptibleInputStreamandTusServletRequest.AbstractITTusFileUploadService.testInterruptedUploadPersistsBytesBeforeHeadResponds) verifying that interrupted uploads properly persist received bytes and update upload offset beforeHEADresume requests respond (tested across Disk, S3, and Azure backends).ASYNC_REVIEW.mdto.gitignore.