Skip to content

fix(compaction): Keep the background mark and result on the current history - #2611

Merged
thomasjiangcy merged 1 commit into
mainfrom
fix/background-compaction-mark-after-replacement
Nov 3, 2026
Merged

thomasjiangcy merged 1 commit into
mainfrom
fix/background-compaction-mark-after-replacement

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Fixes two Cursor Bugbot findings from #2606 that landed on main. They were reported on its last head (28dc7cbd3), and the PR merged before the fix was pushed.

Mark after a replacement (high). The request took markSeq from the projection seqs. Messages kept by a compaction or handoff replacement carry the seqs of their older source events. The job projects with maxSeq: markSeq, so it could stop before the replacement event and summarize empty or truncated history. The mark now does not fall before the replacement event. The swap still finds the cut correctly: kept messages have seqs below the mark, and later native events have seqs above it.

Result after a replacement during the job (medium). The job checked the History version only before the summary call. A replacement during the call let it append a compaction_prepared event for the old version into the new current history. The job now checks the version again before it writes and returns stale on a mismatch. A replacement between that check and the append is still possible, but the swap and the request check both match historyVersion, so that event is never used. No schema or event store API change.

Both new integration cases in background-compaction-events.test.ts fail without the fix.

via @thomasjiangcy.

--

View Session [Sentry]

…istory

The mark used projection seqs, and messages kept by a replacement carry
the seqs of their older source events. The job reads events up to the
mark, so it could stop before the replacement and summarize too little.
The mark now does not fall before the replacement event.

The job also checks the History version again before it writes the
result, so a replacement during the summary call drops the result.
@vercel

vercel Bot commented Nov 3, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
junior-docs Ready Ready Preview Nov 3, 2026 2:40pm UTC

Request Review

@github-actions github-actions Bot added the risk: medium PR risk score: medium label Nov 3, 2026
@thomasjiangcy
thomasjiangcy merged commit 2169d9a into main Nov 3, 2026
50 of 62 checks passed
@thomasjiangcy
thomasjiangcy deleted the fix/background-compaction-mark-after-replacement branch November 3, 2026 14:53

This branch was successfully deployed

1 active deployment
Preview – junior-docs — 3ba48131 Deployed Nov 3, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant