fix: make no-op deleteBefore advance cursor in commitQCState and simplify deleteBefore API#3122
Merged
Merged
Conversation
|
The latest Buf updates on your PR. Results from workflow Buf / buf (pull_request).
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3122 +/- ##
==========================================
- Coverage 58.58% 58.58% -0.01%
==========================================
Files 2099 2099
Lines 173525 173522 -3
==========================================
- Hits 101657 101654 -3
Misses 62805 62805
Partials 9063 9063
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
1335a24 to
82edd6d
Compare
In no-op mode (persistence disabled), deleteBefore returned early without advancing s.next. When MaybePruneAndPersist was called with both an anchor and commitQCs, the anchor's persistCommitQC would fail with "out of sequence" because the cursor was stale. Fix by separating the idx==0 early return from the iw.Get() call so the cursor advances regardless of whether a WAL is present. Also improve no-op tests for all three persisters (blocks, commitqcs, globalblocks) to exercise prune-then-persist paths, and add an early return to indexedWAL.TruncateAll when already empty. Made-with: Cursor
82edd6d to
e3e6b07
Compare
arajasek
approved these changes
Mar 26, 2026
pompon0
approved these changes
Mar 26, 2026
jewei1997
pushed a commit
that referenced
this pull request
Mar 30, 2026
…lify deleteBefore API (#3122) ## Summary - In no-op mode (persistence disabled), `commitQCState.deleteBefore` returned early without advancing `s.next`. When `MaybePruneAndPersist` was called with both an anchor and commitQCs, the anchor's `persistCommitQC` would fail with "out of sequence" because the cursor was stale. - Fix by ensuring the cursor advances regardless of whether a WAL is present. - Remove the redundant `idx` parameter from `deleteBefore` — in production, `idx` was always derived from the anchor's `CommitQC.Index()`. The new signature is `deleteBefore(anchor *types.CommitQC)`. - Refactor tests to go through the production API (anchors) instead of internal truncation-only calls. Crash recovery tests now simulate crashes via WAL file manipulation rather than calling internal methods directly. - Improve no-op tests for blocks and commitqcs persisters to exercise prune-then-persist paths that would have caught this. ## Test plan - `TestNoOpCommitQCPersister` persists QCs, prunes with a future anchor, then appends more — verifies cursor advances correctly in no-op mode - `TestNoOpBlockPersister` exercises multiple `MaybePruneAndPersistLane` calls verifying `afterEach` callbacks fire in no-op mode - `TestCommitQCDeleteBeforePastAllCrashRecovery` and `TestCommitQCDeleteBeforeWithAnchorRecovers` now simulate crashes via `clearCommitQCWAL` instead of internal API - All existing persist tests pass
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.
Summary
commitQCState.deleteBeforereturned early without advancings.next. WhenMaybePruneAndPersistwas called with both an anchor and commitQCs, the anchor'spersistCommitQCwould fail with "out of sequence" because the cursor was stale.idxparameter fromdeleteBefore— in production,idxwas always derived from the anchor'sCommitQC.Index(). The new signature isdeleteBefore(anchor *types.CommitQC).Test plan
TestNoOpCommitQCPersisterpersists QCs, prunes with a future anchor, then appends more — verifies cursor advances correctly in no-op modeTestNoOpBlockPersisterexercises multipleMaybePruneAndPersistLanecalls verifyingafterEachcallbacks fire in no-op modeTestCommitQCDeleteBeforePastAllCrashRecoveryandTestCommitQCDeleteBeforeWithAnchorRecoversnow simulate crashes viaclearCommitQCWALinstead of internal API