{"record":{"id":"eca47e50ca48ddd0","repo":"nats-io/nats-server","slug":"snapshot-corrupt-checksums-did-not-match","errorCode":null,"errorMessage":"Snapshot corrupt, checksums did not match","messagePattern":"Snapshot corrupt, checksums did not match","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/raft.go","lineNumber":2046,"sourceCode":"\tn.dios.release()\n\n\tif err != nil {\n\t\tn.warn(\"Error reading snapshot: %v\", err)\n\t\treturn nil, err\n\t}\n\tif len(buf) < minSnapshotLen {\n\t\tn.warn(\"Snapshot corrupt, too short\")\n\t\treturn nil, errSnapshotCorrupt\n\t}\n\n\t// Check to make sure hash is consistent.\n\thoff := len(buf) - 8\n\tlchk := buf[hoff:]\n\tn.hh.Reset()\n\tn.hh.Write(buf[:hoff])\n\tvar hb [highwayhash.Size64]byte\n\tif !bytes.Equal(lchk[:], n.hh.Sum(hb[:0])) {\n\t\tn.warn(\"Snapshot corrupt, checksums did not match\")\n\t\treturn nil, errSnapshotCorrupt\n\t}\n\n\tvar le = binary.LittleEndian\n\tlps := le.Uint32(buf[16:])\n\tsnap := &snapshot{\n\t\tlastTerm:  le.Uint64(buf[0:]),\n\t\tlastIndex: le.Uint64(buf[8:]),\n\t\tpeerstate: buf[20 : 20+lps],\n\t\tdata:      buf[20+lps : hoff],\n\t}\n\n\t// We had a bug in 2.9.12 that would allow snapshots on last index of 0.\n\t// Detect that and continue anyway, nothing else we can do about it.\n\tif snap.lastIndex == 0 {\n\t\tn.warn(\"Snapshot with last index 0 is invalid, cleaning up\")\n\t\tos.Remove(n.snapfile)\n\t\tn.snapfile = _EMPTY_","sourceCodeStart":2028,"sourceCodeEnd":2064,"githubUrl":"https://github.com/nats-io/nats-server/blob/3a66a489d262bf89b71a71c955c94920394532f3/server/raft.go#L2028-L2064","documentation":"The trailing 8-byte highwayhash checksum embedded in the snapshot file does not match the hash recomputed over the rest of the buffer, meaning the snapshot payload was corrupted (torn write, bit rot, or partial file). loadLastSnapshot refuses to trust the contents and returns the errSnapshotCorrupt sentinel so the caller falls back to WAL replay or a fresh snapshot from the leader.","triggerScenarios":"Thrown at server/raft.go:2046 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Delete or move aside the corrupt snapshot file so the node re-snapshots from the leader on next catchup","Verify disk health and filesystem durability (fsync/direct-io) settings that could allow torn writes","Restore a known-good snapshot backup if available to avoid full catchup"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"3a66a489d262bf89b71a71c955c94920394532f3","analyzedAt":"2026-09-02T04:41:54.247Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}