raft: reset the leader on entering candidate state

Not resetting a leader causes vote requests to be ignored instead of
rejected which will make voting round to take more time to fail and may
slow down new leader election.
This commit is contained in:
Gleb Natapov
2021-03-04 13:29:04 +02:00
parent 20d6bb36cd
commit a849246cfc

View File

@@ -161,6 +161,10 @@ void fsm::become_follower(server_id leader) {
}
void fsm::become_candidate() {
// When starting a campain we need to reset current leader otherwise
// disruptive server prevention will stall an election if quorum of nodes
// start election together since each one will ignore vote requests from others
_current_leader = {};
_state = candidate{};
_tracker = std::nullopt;
_log_limiter_semaphore = std::nullopt;