raft: persist vote for self together with term bump
Commit c9155ac8 ("raft: persist new term and vote separately") made the nodes persist new term and vote separately, using 2 WAL writes. Writing the term first is needed to flush all the ongoing transactions, so that the node's vclock is updated and can be checked against the candidate's vclock. Otherwise it could happen that the node persists a vote for some candidate only to find that it's vclock would actually become incomparable with the candidate's. Actually, this guard is not needed when checking a vote for self, because a node can always vote for self. Besides, splitting term bump and vote can lead to increased probability of split-vote. It may happen that a candidate bumps and broadcasts the new term without a vote, making other nodes vote for self. Let's go back to writing term and vote together for self votes. This change makes raft candidate persist term bump and vote for self in one WAL write instead of two, so all the tests which count WAL writes or expect 2 separate state updates for term and vote are rewritten. Prerequisite #8497 NO_DOC=not user-visible NO_CHANGELOG=not user-visible (cherry picked from commit 8a124e50)
Showing
- src/lib/raft/raft.c 9 additions, 9 deletionssrc/lib/raft/raft.c
- test/replication/election_basic.result 16 additions, 21 deletionstest/replication/election_basic.result
- test/replication/election_basic.test.lua 15 additions, 17 deletionstest/replication/election_basic.test.lua
- test/unit/raft.c 58 additions, 72 deletionstest/unit/raft.c
Loading
Please register or sign in to comment