Absorb in flight backup copies superseded by a truncation#775
Merged
hg-ms merged 3 commits intoJul 24, 2026
Conversation
The pre-truncation queue surgery only removes queued copy items; an item the backup thread has already dequeued reads the source after the truncation and fails. Such a failure is provably inconsequential - the truncating item still queued behind it discards the copied range and the subsequent items re-append the rewritten content - so it is now skipped instead of disrupting the whole storage. Genuine copy failures without a superseding truncation or deletion behind them escalate exactly as before.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR hardens the storage backup pipeline against a race where a live-file truncation (or deletion) occurs while the backup thread is mid-copy, causing a short read and an otherwise avoidable storage-wide disruption.
Changes:
- Reorders backup-queue mutations in
StorageFileWriterBackuppingso truncation/deletion markers are enqueued before the physical operation (closing the race where the backup thread could miss the superseding marker). - Extends
StorageBackupItemQueue.processNextItemto absorbStorageExceptionBackupCopyingfailures when the failed in-flight copy is superseded by a pending truncation (discarding that range) or deletion for the same file. - Updates queue-trimming documentation to clarify that it only affects queued items and that in-flight copies are handled during processing.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| storage/storage/src/main/java/org/eclipse/store/storage/types/StorageFileWriterBackupping.java | Enqueues truncation/deletion markers before physical truncate/delete to ensure superseding items are visible when an in-flight copy fails. |
| storage/storage/src/main/java/org/eclipse/store/storage/types/StorageBackupItemQueue.java | Adds failure-absorption logic for superseded in-flight copies and documents/implements the pending-superseder scan. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
zdenek-jonas
approved these changes
Jul 23, 2026
fh-ms
approved these changes
Jul 24, 2026
hg-ms
deleted the
Absorb-in-flight-backup-copies-superseded-by-a-truncation
branch
July 24, 2026 08:14
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.
Problem
When the backup is enabled, a live-file truncation (notably the transactions-log compaction's truncate-and-rewrite) can land while the backup thread is mid-copy of that file. The pre-truncation queue surgery (trimPendingCopyItemsBeyond) only
removes queued copy items — an item the backup thread has already dequeued is invisible to it. That in-flight copy then reads past the new file end, fails the byte-count check, and escalates to a storage-wide disruption — even though the
truncation that shortened the source makes the copied range irrelevant.
Latent since transaction-file housekeeping was introduced; turned from silent backup corruption into a loud fail-stop once copy sites gained byte-count validation.
Fix
StorageBackupItemQueue.processNextItem now inspects the queue when a copy fails: if a truncation discarding the copied range — or a deletion of the whole file — is queued behind the failed item, the failure is absorbed (debug-logged, not
escalated). The trailing items reconcile the backup, so skipping is a no-op. Genuine copy failures, with nothing superseding them, escalate exactly as before.
To make that check sound, StorageFileWriterBackupping enqueues the truncation/deletion marker before the physical op rather than after. Since the physical op is what fails the copy, the marker is guaranteed present when the absorption check
runs — closing the window where the check could miss it and escalate spuriously.
Scope & safety