nats-io/nats-server · error
Snapshot with last index 0 is invalid, cleaning up
Error message
Snapshot with last index 0 is invalid, cleaning up
What it means
The loaded snapshot has lastIndex == 0, produced by a bug in v2.9.12 that allowed empty snapshots. Such a snapshot carries no usable state, so it is cleaned up and the node proceeds without it (WAL/leader catchup re-establishes state).
Source
Thrown at server/raft.go:2062
var hb [highwayhash.Size64]byte
if !bytes.Equal(lchk[:], n.hh.Sum(hb[:0])) {
n.warn("Snapshot corrupt, checksums did not match")
return nil, errSnapshotCorrupt
}
var le = binary.LittleEndian
lps := le.Uint32(buf[16:])
snap := &snapshot{
lastTerm: le.Uint64(buf[0:]),
lastIndex: le.Uint64(buf[8:]),
peerstate: buf[20 : 20+lps],
data: buf[20+lps : hoff],
}
// We had a bug in 2.9.12 that would allow snapshots on last index of 0.
// Detect that and continue anyway, nothing else we can do about it.
if snap.lastIndex == 0 {
n.warn("Snapshot with last index 0 is invalid, cleaning up")
os.Remove(n.snapfile)
n.snapfile = _EMPTY_
return nil, errNoSnapAvailable
}
return snap, nil
}
// Leader returns if we are the leader for our group.
// We use an atomic here now vs acquiring the read lock.
func (n *raft) Leader() bool {
if n == nil {
return false
}
return n.leaderState.Load()
}
// LeaderSince returns how long we have been leader for,View on GitHub (pinned to 3a66a489d2)
Solutions
- Upgrade from 2.9.12 to a fixed release
- No data recovery needed: index-0 snapshots hold nothing of value
- The node re-snapshots normally on next snapshot cycle
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at server/raft.go:2062 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of nats-io/nats-server@3a66a489d2 (2026-09-02).
Data as JSON: /api/errors/aa6b4dbd38b4a043.
Report an issue: GitHub.