Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion server/raft.go
Original file line number Diff line number Diff line change
Expand Up @@ -3474,14 +3474,23 @@ func (n *raft) processAppendEntry(ae *appendEntry, sub *subscription) {

// Are we receiving from another leader.
if n.State() == Leader {
// If we are the same we should step down to break the tie.
if lterm >= n.term {
// If the append entry term is newer than the current term, erase our
// vote.
if lterm > n.term {
n.term = lterm
n.vote = noVote
n.writeTermVote()
} else {
assert.Unreachable(
"Two leaders using the same term",
map[string]any{
"Node id": n.id,
"Node term": n.term,
"AppendEntry id": ae.leader,
"AppendEntry term": ae.term,
"AppendEntry lterm": ae.lterm,
})
}
n.debug("Received append entry from another leader, stepping down to %q", ae.leader)
n.stepdownLocked(ae.leader)
Expand Down
Loading