[FIXED] NRG layer could loop if leader asked for an item and we have 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>
This commit is contained in:
Derek Collison
2023-08-25 11:03:20 -07:00
committed by GitHub

View File

@@ -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