Skip to content

[7.x] (#8921) Fence local writes against step-down with a role lock - #8942

Merged
Amaury Chamayou (achamayou) merged 3 commits into
release/7.xfrom
backport-7.x-8921
Dec 4, 2026
Merged

Amaury Chamayou (achamayou) merged 3 commits into
release/7.xfrom
backport-7.x-8921

Conversation

@cjen1-msft

Copy link
Copy Markdown
Contributor

Backports #8921 to release/7.x to fence local writers against leadership step-down with a role lock and prevent stepped-down followers from diverging on Merkle history (seen in CI as verify_root_signatures failures).

Structured as three commits so the main change is verified by Backport checks as an unchanged cherry-pick:

  1. Prep commit aligning conflicting 8.0-only context in cft.h and test files with 25eaec325^.
  2. Unchanged cherry-pick of 25eaec325 (Fence local writes against step-down with a role lock #8921).
  3. Fixup commit reverting the temporary 8.0 context in cft.h (#include <format>, trace::tick) and restoring 7.x test files with next_txid().value() updates, 7.x baseline seqno adjustments in view_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 is commit_lock -> consensus lock -> role_rwlock -> maps_lock -> version_lock -> history lock. next_txid() returns std::optional<ccf::TxID> (empty when the node does not accept local writes).

cjen1-msft and others added 3 commits December 4, 2026 15:05
Temporarily align conflicting context in cft.h and test files with
25eaec3^ so #8921 cherry-picks cleanly. Reverted in the follow-up
fixup commit.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 8734db1e936445abbf809bd1a0477afa
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
@cjen1-msft
cjen1-msft requested a review from a team as a code owner December 4, 2026 15:06
@cjen1-msft cjen1-msft added the 7.x-backport Highlight PRs targeting the 7.x branch label Dec 4, 2026
Copilot AI balanced review requested due to automatic review settings December 4, 2026 15:06

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 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

@achamayou
Amaury Chamayou (achamayou) added this pull request to the merge queue Dec 4, 2026
Merged via the queue into release/7.x with commit 47313fc Dec 4, 2026
34 checks passed
@achamayou
Amaury Chamayou (achamayou) deleted the backport-7.x-8921 branch December 4, 2026 15:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

7.x-backport Highlight PRs targeting the 7.x branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants