mirror of
https://github.com/gogrlx/nats-server.git
synced 2026-04-16 19:14:41 -07:00
Stabilty improvements for split votes.
Was incorrectly resetting term and exiting on failed vote. Also was not properly stepping down when we were a candidate and saw an entry from a leader. Signed-off-by: Derek Collison <derek@nats.io>
This commit is contained in:
@@ -1361,13 +1361,6 @@ func (n *raft) runAsCandidate() {
|
||||
n.switchToLeader()
|
||||
return
|
||||
}
|
||||
} else {
|
||||
n.Lock()
|
||||
n.term = vresp.term
|
||||
n.writeTermVote()
|
||||
n.Unlock()
|
||||
n.switchToFollower(noLeader)
|
||||
return
|
||||
}
|
||||
case vreq := <-n.reqs:
|
||||
n.processVoteRequest(vreq)
|
||||
@@ -1440,6 +1433,15 @@ func (n *raft) processAppendEntry(ae *appendEntry, sub *subscription) {
|
||||
return
|
||||
}
|
||||
|
||||
// If we received an append entry as a candidate we should convert to a follower.
|
||||
if n.state == Candidate {
|
||||
n.debug("Received append entry in candidate state from %q, converting to follower", ae.leader)
|
||||
n.term = ae.term
|
||||
n.Unlock()
|
||||
n.stepdown <- ae.leader
|
||||
return
|
||||
}
|
||||
|
||||
// Catching up state.
|
||||
catchingUp := n.catchup != nil
|
||||
// Is this a new entry or a replay on startup?
|
||||
|
||||
Reference in New Issue
Block a user