Repository navigation
rollback: don't revive pruned deltas on reopen - #973
Open
citizen-stig wants to merge 1 commit into
Open
citizen-stig wants to merge 1 commit into
citizen-stig wants to merge 1 commit into
Conversation
`writeout_start` returns the live range the manifest is written with, before `writeout_end` prunes the log. It returned a range that still covered pruned deltas, and a reopen loaded them back: - After pruning the oldest delta it returned the pre-prune start, so a reopened log held one delta more than `max_rollback_log_len`. Pruning only dropped one delta per sync, so the log never shrank back. - After a truncate it returned `min(seglog start, pending_truncate)`. When the truncate removed every delta, `pending_truncate` points at the last pruned delta, so the range revived it. A rollback after reopen then succeeded and rewound one commit past the rollback window. With `max_rollback_log_len(1)`: commit 1, 2, 3, `rollback(1)` succeeds and a second fails; after a reopen `rollback(1)` succeeded and restored the state after commit 1. Derive the range from the deltas still in memory, which is what stays live, and use (0, 0) when none do. Prune until the log fits its length, so a log opened with a smaller length shrinks on the next commit. Writing the pre-prune start was also unsafe on its own: `writeout_end` deletes the segments before the new start, which the manifest still pointed into until the next sync. Found by the concurrent_rollback fuzz target. Co-Authored-By: Claude Opus 5.5 <[email protected]>
citizen-stig
force-pushed
the
nikolai/fix-rollback-reopen-resurrects-pruned
branch
from
November 24, 2026 22:45
b082064 to
43b16ba
Compare
citizen-stig
marked this pull request as ready for review
November 25, 2026 07:58
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.
writeout_startreturns the live range that goes into the manifest, but it computed that range before pruning, so the manifest could still cover pruned deltas and a reopen loaded them back:max_rollback_log_len + 1deltas. Pruning dropped only one delta per sync, so the log never shrank back.min(seglog start, pending_truncate), andpending_truncatethen points at the last pruned delta. After a reopen,rollbacksucceeded one commit past the rollback window.Repro with
max_rollback_log_len(1): commit 1, 2, 3;rollback(1)succeeds and a second one fails; reopen;rollback(1)succeeds again and restores the state after commit 1.Fix: derive the range from the deltas still in memory (
(0, 0)if none), and prune until the log fitsmax_rollback_log_len, so reopening with a smaller length shrinks the log on the next commit.Writing the pre-prune start was also unsafe on its own:
writeout_enddeletes the segments before the new start, which the manifest kept pointing into until the next sync.Tests (the new ones fail without the fix):
rollback::tests::rollback_writeout_truncate_to_empty_after_prune(new).rollback_writeout_start_and_endnow expects the post-prune start.tests/rollback.rs:test_rollback_log_len_holds_across_reopen,test_rollback_log_shrinks_to_smaller_len_on_reopen.Found by the
concurrent_rollbackfuzz target.🤖 Generated with Claude Code