Repository navigation
Reject KV map acquisition across rollback - #8799
Draft
Eddy Ashton (eddyashton) wants to merge 8 commits into
Draft
Eddy Ashton (eddyashton) wants to merge 8 commits into
Eddy Ashton (eddyashton) wants to merge 8 commits into
Conversation
Add regression coverage for mixed snapshots and preserve read-only completion through already acquired handles. Cover reserved handle acquisition on either side of rollback. The mixed-snapshot assertion requires the following fix. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Capture the store rollback epoch with the read snapshot and check it before exposing a newly acquired map view. Preserve existing handles and read-only completion, and leave write-only reserved transactions on their existing reservation validation path. Capture proposal history snapshots and their epoch under the store version lock. Reuse CompactedVersionConflict so callers retain their existing retry handling. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Remove assertions requiring cross-rollback acquisition to succeed. Retain removed-map handles, unaffected-map epoch checks, replacement-version reuse, and stale-writer rejection without restarting the transaction. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…pp-kv-semantics-discussion
Check a local copy of the captured rollback count so clang-tidy can track optional validity, and avoid dereferencing the read TxID solely for the conflict message. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…pp-kv-semantics-discussion
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Rollback during KV-backed endpoint lookup can escape the retry and HTTP exception handlers and reach the task worker’s abort handler.
2 open issues
What changed in this PR
This PR addresses the mixed-snapshot behavior identified in #8795 by tying CCF transaction snapshots to a store rollback epoch and rejecting new map acquisitions after rollback.
Changes:
- Capture and validate the rollback epoch, including explicitly selected proposal snapshots.
- Preserve existing handles and reserved-transaction behavior while reusing
CompactedVersionConflictfor retries. - Update rollback regression scenarios, trace requirements, and release notes.
Custom instructions used
.github/instructions/reviewing.instructions.md
| File | Description |
|---|---|
tests/kv_trace_validation.py |
Require the rollback map-acquisition trace scenario. |
src/node/test/retry_on_compacted_version_conflict.cpp |
Adapt the test store to the expanded snapshot API. |
src/node/rpc/frontend.h |
Pass the rollback epoch with proposal snapshots. |
src/kv/tx.cpp |
Capture the epoch and reject acquisitions after rollback. |
src/kv/tx_pimpl.h |
Store the transaction's read rollback epoch. |
src/kv/test/kv_trace.cpp |
Add and update rollback acquisition scenarios. |
src/kv/test/kv_test.cpp |
Cover reserved handles acquired after rollback. |
src/kv/store.h |
Return rollback epochs alongside snapshot metadata. |
src/kv/kv_types.h |
Extend the abstract store snapshot API. |
src/kv/compacted_version_conflict.h |
Document rollback-triggered retry conflicts. |
src/kv/committable_tx.h |
Record epochs for explicitly selected snapshots. |
include/ccf/tx.h |
Validate the epoch after capturing a new map view. |
.changes/kv-rollback-map-acquisition.fixed.md |
Describe the rollback consistency fix. |
Review effort: Balanced
Check captured validity epochs while acquiring map state, before recording acquisition success. Permit unaffected maps across rollback and invalidate histories consistently on rollback, snapshot installation and map swaps. Keep the Lean model abstract: acquired birth and revision identities must match the captured snapshot, with conservative refusal permitted only after crossing a truncating rollback. Update replay, proofs and rollback fixtures to validate the observable outcomes. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…pp-kv-semantics-discussion
This branch has not been deployed
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.


Prevent a C++ KV transaction from combining map views from different rollback branches. The issue is described in the original discussion and the model-based opacity follow-up, #8795.
Transactions capture the store's validity epoch with their read version. Each map tracks its last-observed epoch; new acquisitions check compatibility under the map lock before returning state or recording successful acquisition. This permits unaffected maps across rollback while rejecting histories invalidated or subsequently written on a replacement branch. Snapshot installation and map swaps also invalidate replaced histories.
The Lean model specifies original map birth/revision identities and retention, rather than implementation epochs. It permits conservative refusal only after the transaction's captured snapshot crosses a truncating rollback of its store. Replay checks successful acquisitions and explicit unavailability against those transitions.
Safety and compatibility
Acquisition can be conservatively rejected even when the requested revision survives, for example when rollback removes a newer revision of the same map. Existing captured handles remain usable, and read-only transactions can complete using those views.
Acquisition conflicts use the existing
CompactedVersionConflict, preserving callers' retry handling. The entire attempt must be retried after an acquisition conflict.Validation
Post-merge KV, frontend, node-frontend and retry-helper unit suites pass. Lean build, kernel/axiom checks, import checks, lint/format, all 70 replay fixtures and captured C++ suite/fuzz traces pass. Kernel checks required the no-sandbox option because bubblewrap permissions were unavailable locally.