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
15 changes: 11 additions & 4 deletions server/raft.go
Original file line number Diff line number Diff line change
Expand Up @@ -3764,11 +3764,19 @@ func (n *raft) processAppendEntryResponse(ar *appendEntryResponse) {

if ar.success {
// The remote node successfully committed the append entry.
// They agree with our leadership and are happy with the state of the log.
// In this case ar.term doesn't matter.
n.trackResponse(ar)
arPool.Put(ar)
} else if ar.reply != _EMPTY_ {
// The remote node didn't commit the append entry, and they believe they
// are behind and have specified a reply subject, so let's try to catch them up.
// In this case ar.term was populated with the remote's pterm.
n.catchupFollower(ar)
} else if ar.term > n.term {
// The remote node didn't commit the append entry, it looks like
// they are on a newer term than we are. Step down.
// In this case ar.term was populated with the remote's term.
n.Lock()
n.term = ar.term
n.vote = noVote
Expand All @@ -3777,10 +3785,9 @@ func (n *raft) processAppendEntryResponse(ar *appendEntryResponse) {
n.stepdownLocked(noLeader)
n.Unlock()
arPool.Put(ar)
} else if ar.reply != _EMPTY_ {
// The remote node didn't commit the append entry and they are
// still on the same term, so let's try to catch them up.
n.catchupFollower(ar)
} else {
// Ignore, but return back to pool.
arPool.Put(ar)
}
}

Expand Down
Loading