Skip to content

Commit

Permalink
[IMPROVED] Leader transfer process (#4143)
Browse files Browse the repository at this point in the history
When doing a leader transfer clear vote state on leader and when
non-chosen peers receive the update.

Signed-off-by: Derek Collison <derek@nats.io>
  • Loading branch information
derekcollison committed May 10, 2023
2 parents c5c5a34 + 717afae commit 7248560
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions server/raft.go
Expand Up @@ -1352,6 +1352,10 @@ func (n *raft) StepDown(preferred ...string) error {
}
}

// Clear our vote state.
n.vote = noVote
n.writeTermVote()

stepdown := n.stepdown
prop := n.prop
n.Unlock()
Expand Down Expand Up @@ -3196,6 +3200,10 @@ func (n *raft) processAppendEntry(ae *appendEntry, sub *subscription) {
// Here we can become a leader but need to wait for resume of the apply channel.
n.lxfer = true
}
} else {
// Since we are here we are not the chosen one but we should clear any vote preference.
n.vote = noVote
n.writeTermVote()
}
}
case EntryAddPeer:
Expand Down

0 comments on commit 7248560

Please sign in to comment.