MB-72716: Fix miscalculation of rollback points#2370
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses accidental removal of the latest persisted snapshot from the Scorch root boltDB by refactoring snapshot “liveness”/protection selection and aligning purge behavior with those rules, plus updating tests to validate the retention guarantees.
Changes:
- Reorders Scorch initialization so rollback/snapshot retention options are parsed before opening/loading bolt state.
- Refactors snapshot retention to distinguish “live snapshots” from “protected snapshots”, ensuring the latest snapshot is always retained in bolt.
- Updates/rewrites rollback-related tests to seed bolt snapshots directly and validate purge/retention invariants.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| index/scorch/scorch.go | Parse scorch rollback/snapshot options before opening/loading bolt to avoid retention logic using zero/default values. |
| index/scorch/persister.go | Refactors snapshot retention (live/protected), purge behavior, and related persistence flow. |
| index/scorch/rollback_test.go | Reworks tests to seed bolt snapshots and assert latest-snapshot retention during purge scenarios. |
| index/scorch/merge.go | Ensures merged segment filenames are tracked before work proceeds (supports correct cleanup/unmarking on error paths). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
CascadingRadium
requested review from
a team,
Likith101,
Samsonnyyeet,
Thejas-bhat,
capemox,
maneuvertomars and
steveyen
July 3, 2026 08:54
Likith101
approved these changes
Jul 6, 2026
maneuvertomars
approved these changes
Jul 6, 2026
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.
liveand pass it on to the time series mechanism that will protect/retain the number of snapshots configured in scorch -NumSnapshotsToKeeprollbackRetentionFactorconfig validation was broken and errored on valid input instead of invalid. Corrected the condition and added a0 ≤ r ≤ 1bounds check.closeChselect after handing a persist off to the introducer, the introducer always completes and closes applies the persist unconditionally, so that branch was dead code.time.Sleep()to simulate scenarios. Fixed them with deterministic tests that capture the same semantic meaning without using sleeps.