{"record":{"id":"b310899dcdd2250c","repo":"nats-io/nats-server","slug":"error-truncating-wal-v","errorCode":null,"errorMessage":"Error truncating WAL: %v","messagePattern":"Error truncating WAL: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/raft.go","lineNumber":4367,"sourceCode":"\t\t}\n\t\t// Make sure to reset commit and applied if above\n\t\tif n.commit > n.pindex {\n\t\t\tn.commit = n.pindex\n\t\t}\n\t\tif n.processed > n.commit {\n\t\t\tn.processed = n.commit\n\t\t}\n\t\tif n.applied > n.processed {\n\t\t\tn.applied = n.processed\n\t\t}\n\t\t// Refresh bytes count after truncate.\n\t\tvar state StreamState\n\t\tn.wal.FastState(&state)\n\t\tn.bytes = state.Bytes\n\t}()\n\n\tif err := n.wal.Truncate(index); err != nil {\n\t\tn.warn(\"Error truncating WAL: %v\", err)\n\t\tn.setWriteErrLocked(err)\n\t\treturn\n\t}\n\t// Set after we know we have truncated properly.\n\tn.pterm, n.pindex = term, index\n\n\t// Invalidate cached entries the WAL no longer has.\n\tif index == 0 {\n\t\tn.resetPendingEntries()\n\t} else {\n\t\tfor k, ae := range n.pae {\n\t\t\tif k > index {\n\t\t\t\tn.paeBytes -= n.entryStoreSize(ae)\n\t\t\t\tdelete(n.pae, k)\n\t\t\t}\n\t\t}\n\t}\n","sourceCodeStart":4349,"sourceCodeEnd":4385,"githubUrl":"https://github.com/nats-io/nats-server/blob/3a66a489d262bf89b71a71c955c94920394532f3/server/raft.go#L4349-L4385","documentation":"wal.Truncate(index) failed while the node was truncating its WAL to a given term/index (e.g. after a snapshot install or conflict resolution). The error is recorded via setWriteErrLocked, which typically disables the store since the WAL is now in an unknown state; pterm/pindex are intentionally not updated.","triggerScenarios":"Thrown at server/raft.go:4367 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check disk space, permissions, and filesystem errors on the WAL directory","Restart the node so the WAL recovery/replay logic re-establishes consistency","If the WAL is unrecoverable, reset the stream/raft state and re-sync from peers"],"exampleFix":null,"handlingStrategy":"fallback","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-08T10:18:20.063Z"}