Skip to content

Commit

Permalink
[FIXED] NRG layer could loop if leader asked for an item and we have …
Browse files Browse the repository at this point in the history
…none. (#4432)

If a leader is asked for an item and we have no items left, make sure to
also step-down.

Signed-off-by: Derek Collison <derek@nats.io>
  • Loading branch information
derekcollison committed Aug 25, 2023
2 parents 6df4403 + e5625b9 commit e637f37
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions server/raft.go
Expand Up @@ -2509,6 +2509,10 @@ func (n *raft) catchupFollower(ar *appendEntryResponse) {
}
if err != nil || ae == nil {
n.warn("Could not find a starting entry for catchup request: %v", err)
// If we are here we are seeing a request for an item we do not have, meaning we should stepdown.
// This is possible on a reset of our WAL but the other side has a snapshot already.
// If we do not stepdown this can cycle.
n.stepdown.push(noLeader)
n.Unlock()
arPool.Put(ar)
return
Expand Down

0 comments on commit e637f37

Please sign in to comment.