Repository navigation
[7.x] (#8921) Fence local writes against step-down with a role lock - #8942
Merged
Merged
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> (cherry picked from commit 25eaec3)
Remove temporary 8.0 context from cft.h (#include <format> and trace::tick) and restore 7.x test files with next_txid().value() updates, 7.x baseline seqno adjustments in view_straddling tests, and the new snapshotter rollback tests. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 8734db1e936445abbf809bd1a0477afa
Contributor
There was a problem hiding this comment.
🔵 Needs a closer look
This consensus/KV safety backport changes demotion rollback timing and lock ordering. Builds, tests, and exact cherry-pick verification were unavailable, leaving concurrent step-down and retirement behavior, cft_trace_e2e results, and 7.x/LTS compatibility unconfirmed.
No open issues 🎉
What changed in this PR
Backports #8921 to release/7.x, fencing local writes during leadership changes to prevent KV and Merkle-history divergence.
Changes:
- Adds role-lock permits and moves speculative-state rollback to demotion.
- Rejects stale writes and makes transaction-ID reservation optional.
- Invalidates rolled-back snapshot receipt material and expands regression coverage.
Custom instructions used
Applied the repository guidance supplied in the review context; instruction files were unavailable to load.
| File | Description |
|---|---|
src/node/test/snapshotter.cpp |
Tests rollback of receipt signatures and out-of-order evidence. |
src/node/test/history.cpp |
Adapts transaction-ID reservations to optional results. |
src/node/test/historical_queries.cpp |
Updates signature reservation for optional results. |
src/node/snapshotter.h |
Tracks receipt signature indexes and discards rolled-back material. |
src/node/history.h |
Skips signing when local writes are disabled. |
src/kv/test/null_tx_history.h |
Handles refused signature reservations. |
src/kv/test/kv_test.cpp |
Updates reservation calls for the optional API. |
src/kv/test/kv_serialisation.cpp |
Adapts reserved-transaction setup. |
src/kv/store.h |
Fences publication and checks rollback state before history updates. |
src/kv/kv_types.h |
Defines write permits and updates consensus/Store interfaces. |
src/kv/committable_tx.h |
Guards local write application and snapshot requests. |
src/consensus/aft/test/view_straddling_rollback.cpp |
Moves the stale-writer pause to replication. |
src/consensus/aft/test/view_straddling_history.cpp |
Covers demotion, retirement, write refusal, and re-election. |
src/consensus/aft/test/view_straddling_common.h |
Adds pausable consensus and shared transition helpers. |
src/consensus/aft/cft.h |
Coordinates role locking, demotion rollback, and term initialization. |
.changes/local-writes-fenced-on-step-down.fixed.md |
Describes the user-facing divergence fix. |
Review effort: Balanced
Amaury Chamayou (achamayou)
approved these changes
Dec 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.
Backports #8921 to
release/7.xto fence local writers against leadership step-down with a role lock and prevent stepped-down followers from diverging on Merkle history (seen in CI asverify_root_signaturesfailures).Structured as three commits so the main change is verified by
Backport checksas an unchanged cherry-pick:cft.hand test files with25eaec325^.25eaec325(Fence local writes against step-down with a role lock #8921).cft.h(#include <format>,trace::tick) and restoring 7.x test files withnext_txid().value()updates, 7.x baseline seqno adjustments inview_straddling_*, and the new snapshotter rollback tests.No transitive PRs needed backporting; all conflicts were with 8.0-only changes.
Safety and compatibility
Consensus/KV change matching #8921 on
main. Lock order iscommit_lock -> consensus lock -> role_rwlock -> maps_lock -> version_lock -> history lock.next_txid()returnsstd::optional<ccf::TxID>(empty when the node does not accept local writes).