raft: Implement the PreVote RPC described in thesis section 9.6

This prevents disruption when a node that has been partitioned
away rejoins the cluster.

Fixes #6522
This commit is contained in:
Ben Darnell
2016-10-10 14:32:40 +08:00
parent ca87a13b18
commit 73cae7abd0
7 changed files with 482 additions and 198 deletions

View File

@ -257,6 +257,12 @@ stale log entries:
If candidate receives majority of votes of denials, it reverts back to
follower.
'MsgPreVote' and 'MsgPreVoteResp' are used in an optional two-phase election
protocol. When Config.PreVote is true, a pre-election is carried out first
(using the same rules as a regular election, and no node increases its term
number unless the pre-election indicates that the campaigining node would win.
This minimizes disruption when a partitioned node rejoins the cluster.
'MsgSnap' requests to install a snapshot message. When a node has just
become a leader or the leader receives 'MsgProp' message, it calls
'bcastAppend' method, which then calls 'sendAppend' method to each