nats-io/nats-server · error
Snapshot corrupt, too short
Error message
Snapshot corrupt, too short
What it means
A warning logged by raft.loadLastSnapshot() when the snapshot file read succeeds but is shorter than minSnapshotLen, meaning it is truncated or corrupt. errSnapshotCorrupt is returned, so the snapshot cannot be used for state restoration and the node must recover via WAL or peers.
Source
Thrown at server/raft.go:2035
}
// loadLastSnapshot will load and return our last snapshot.
// Lock should be held.
func (n *raft) loadLastSnapshot() (*snapshot, error) {
if n.snapfile == _EMPTY_ {
return nil, errNoSnapAvailable
}
n.dios.acquire()
buf, err := os.ReadFile(n.snapfile)
n.dios.release()
if err != nil {
n.warn("Error reading snapshot: %v", err)
return nil, err
}
if len(buf) < minSnapshotLen {
n.warn("Snapshot corrupt, too short")
return nil, errSnapshotCorrupt
}
// Check to make sure hash is consistent.
hoff := len(buf) - 8
lchk := buf[hoff:]
n.hh.Reset()
n.hh.Write(buf[:hoff])
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:]),View on GitHub (pinned to 3a66a489d2)
Solutions
- Treat the snapshot as corrupt; remove it so an older snapshot/WAL is used
- Check for interrupted writes or disk corruption in the raft storage directory
- Resync the node from a healthy peer if no valid snapshot exists
- Ensure the storage volume is not filling up or being truncated externally
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at server/raft.go:2035 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/92406999caf6b665.
Report an issue: GitHub.