db/state: clip merge windows that straddle existing files#20974
Merged
Conversation
When the natural merge start falls strictly inside an existing visible file, clipMergeStartToFileBoundary bumps it up to that file's endTxNum. Without this clip, non-power-of-2 step layouts (e.g. after a step-size rebase) let the algorithm propose windows straddling an existing file — staticFilesInRange would then silently drop that file and emit a merged segment that lies about its coverage. Applied to DomainRoTx, HistoryRoTx and InvertedIndexRoTx findMergeRange. Also: wrap walk errors with path context; guard collectTorrentFiles against a missing torrent dir. Fixes #20878. Cherry-pick of #20909 (by @wmitsuda), adapted for this branch.
sudeepdino008
approved these changes
May 4, 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.
Cherry-pick of #20909 (by @wmitsuda), adapted for this branch.
Fixes #20878.
When the natural merge start (endTxNum minus the largest power-of-two step span) falls strictly inside an existing visible file,
clipMergeStartToFileBoundarybumps it up to that file's endTxNum. Without this clip, non-power-of-2 step layouts (e.g. after a step-size rebase) let the algorithm propose windows whosefromlies inside a pre-existing file —staticFilesInRangethen silently drops that file and emits a merged segment that lies about its coverage.Applied to
DomainRoTx,HistoryRoTx, andInvertedIndexRoTxfindMergeRange(this branch has inline merge logic vs. the extractedfindMergeRangeInFileshelper on main).Also: wrap walk errors with path context; guard
collectTorrentFilesagainst a missing torrent dir.