Skip to content

Conversation

@cjen1-msft
Copy link
Contributor

@cjen1-msft cjen1-msft commented Oct 31, 2025

This PR makes raft.h capable to respond to pre-votes, but does not enable the PreVoteCandidate by default.

#7361

To be specific about the changes, this PR should largely be a noop for the existing tests as it does not enable the pre-vote by default and we have no way to do so manually.
(Whether/how to enable pre-vote is very much so up for debate)

If pre-vote is enabled, there are the following changes.

  • periodic
    • If pre-vote-enabled then become a PreVoteCandidate and send RequestVote{.is_pre_vote = true}
  • recv_request_vote
    • If m.is_pre_vote then don't update state
    • Note: will always update the term if necessary (see comment)
  • recv_request_vote_response
    • Guard clauses for receiving a pre-vote response when already a candidate

There is a new trace_scenario.sh to make trace validation for a single test simpler.

Also updated ccfraft.tla to make preVoteStatus per-node rather than a global per-network config.

My aim for this PR is to nail down the raft.h changes wrt trace validation, with the expectation that no end-to-end tests should change (as nothing is enabled yet).
And this will be the PR that gets backported to 6.X (hopefully).

@cjen1-msft cjen1-msft marked this pull request as ready for review October 31, 2025 18:56
@cjen1-msft cjen1-msft requested a review from a team as a code owner October 31, 2025 18:56
Copilot AI review requested due to automatic review settings October 31, 2025 18:56
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request implements the PreVote extension for the Raft consensus protocol to prevent disruption from network-partitioned nodes that can send RequestVote messages but cannot hear AppendEntries from the current leader.

Key changes:

  • Introduces a PreVoteCandidate leadership state where nodes first request speculative pre-votes before starting actual elections
  • Changes preVoteStatus from a global set to a per-server function mapping each server to its PreVote capability set
  • Adds is_pre_vote flag to RequestVote and RequestVoteResponse messages to differentiate pre-vote from actual vote requests

Reviewed Changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tla/consensus/ccfraft.tla Changes preVoteStatus to per-server mapping and updates all references to use indexed access
tla/consensus/Traceccfraft.tla Updates trace validation to handle PreVoteCandidate state and per-server preVoteStatus
tla/consensus/SIMccfraft.tla Updates simulation initialization to use per-server preVoteStatus with consistency constraint
tla/consensus/MCccfraft.tla Updates model checking initialization to use per-server preVoteStatus with consistency constraint
tla/consensus/MCAliases.tla Adds preVoteStatus to debug output and enables trace debugging
tests/raft_scenarios/pre_vote_split New test scenario validating PreVote behavior with mixed PreVote capabilities
tests/raft_scenarios/pre_vote New test scenario validating basic PreVote election and migration behavior
src/kv/kv_types.h Adds PreVoteCandidate to LeadershipState enum
src/consensus/aft/test/driver.h Adds PreVote configuration support and fixes detail value extraction
src/consensus/aft/test/driver.cpp Adds pre_vote_enabled command to test driver
src/consensus/aft/raft_types.h Adds is_pre_vote field to RequestVote and RequestVoteResponse messages
src/consensus/aft/raft.h Implements PreVote logic including become_pre_vote_candidate and vote handling
src/consensus/aft/impl/state.h Adds pre_vote_enabled field to State structure
scripts/trace_scenario.sh New script to build, run, and validate Raft scenarios against TLA+ spec
doc/architecture/consensus/index.rst Adds comprehensive documentation of PreVote extension and migration strategy

@achamayou achamayou enabled auto-merge (squash) November 4, 2025 23:49
@achamayou achamayou merged commit 7a4b211 into main Nov 5, 2025
23 checks passed
@achamayou achamayou deleted the pre-vote branch November 5, 2025 07:40
@cjen1-msft cjen1-msft added auto-backport Automatically backport this PR to LTS branch 6.x-todo PRs which should be backported to 6.x labels Nov 5, 2025
cjen1-msft added a commit to cjen1-msft/CCF that referenced this pull request Nov 5, 2025
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Amaury Chamayou <[email protected]>
Co-authored-by: Amaury Chamayou <[email protected]>
cjen1-msft added a commit to cjen1-msft/CCF that referenced this pull request Nov 5, 2025
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Amaury Chamayou <[email protected]>
Co-authored-by: Amaury Chamayou <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.x-todo PRs which should be backported to 6.x auto-backport Automatically backport this PR to LTS branch run-long-test Run Long Test job

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants