Skip to content

Commit

Permalink
[FIXED] Do not spin on multi-leader with same term. (#4056)
Browse files Browse the repository at this point in the history
If we see another leader with same term we should step down, otherwise
we could spin with catchups and WAL truncates.

Signed-off-by: Derek Collison <derek@nats.io>
  • Loading branch information
derekcollison committed Apr 14, 2023
2 parents 94e62cc + 66ca46e commit 816cd82
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion server/raft.go
Expand Up @@ -2927,7 +2927,8 @@ func (n *raft) processAppendEntry(ae *appendEntry, sub *subscription) {

// Are we receiving from another leader.
if n.state == Leader {
if ae.term > n.term {
// If we are the same we should step down to break the tie.
if ae.term >= n.term {
n.term = ae.term
n.vote = noVote
n.writeTermVote()
Expand Down

0 comments on commit 816cd82

Please sign in to comment.