Skip to content

db/state: clip merge windows that straddle existing files#20974

Merged
sudeepdino008 merged 1 commit into
performancefrom
cherry-pick-20909-performance
May 4, 2026
Merged

db/state: clip merge windows that straddle existing files#20974
sudeepdino008 merged 1 commit into
performancefrom
cherry-pick-20909-performance

Conversation

@AskAlexSharov

Copy link
Copy Markdown
Collaborator

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, 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 whose from lies inside a pre-existing file — staticFilesInRange then silently drops that file and emits a merged segment that lies about its coverage.

Applied to DomainRoTx, HistoryRoTx, and InvertedIndexRoTx findMergeRange (this branch has inline merge logic vs. the extracted findMergeRangeInFiles helper on main).

Also: wrap walk errors with path context; guard collectTorrentFiles against a missing torrent dir.

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.
@AskAlexSharov AskAlexSharov enabled auto-merge (squash) May 4, 2026 11:19
@AskAlexSharov AskAlexSharov disabled auto-merge May 4, 2026 11:19
@sudeepdino008 sudeepdino008 merged commit ed1b6a4 into performance May 4, 2026
35 of 36 checks passed
@sudeepdino008 sudeepdino008 deleted the cherry-pick-20909-performance branch May 4, 2026 11:20
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