Skip to content

fix: hold upload lock during stream interruption until data is persisted - #136

Merged
tomdesair merged 1 commit into
masterfrom
bugfix/hold-lock-during-stream-interruption
Sep 27, 2026
Merged

tomdesair merged 1 commit into
masterfrom
bugfix/hold-lock-during-stream-interruption

Conversation

@tomdesair

Copy link
Copy Markdown
Owner

Summary

When an in-progress upload is interrupted (for example, upon upload pause followed immediately by a resume HEAD request), the uploading thread must hold its exclusive upload lock while sending and persisting buffered in-flight bytes to storage and updating UploadInfo metadata.

Previously, InterruptibleInputStream.interrupt() released the lock prematurely before the upload thread finished persisting buffered bytes to the underlying storage backend. When a resume HEAD request arrived within the same second, it acquired the lock and read stale UploadInfo before the upload thread could flush/commit its buffered data, causing data loss and progress rollbacks.

Changes

  • Removed premature lock release from InterruptibleInputStream.interrupt(). The lock remains held by the uploading thread until its write operation finishes persisting buffered bytes and updating UploadInfo metadata, releasing the lock in the standard try-finally block in TusFileUploadService.process().
  • Cleaned up unreleased uploadLock references and accessors from InterruptibleInputStream and TusServletRequest.
  • Added multi-backend integration test (AbstractITTusFileUploadService.testInterruptedUploadPersistsBytesBeforeHeadResponds) verifying that interrupted uploads properly persist received bytes and update upload offset before HEAD resume requests respond (tested across Disk, S3, and Azure backends).
  • Added ASYNC_REVIEW.md to .gitignore.

- 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.
@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 94.902% (-0.01%) from 94.913% — bugfix/hold-lock-during-stream-interruption into master

@tomdesair
tomdesair merged commit 79986c5 into master Sep 27, 2026
13 checks passed
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.

2 participants