nats-io/nats-server · error
Error truncating WAL: %v
Error message
Error truncating WAL: %v
What it means
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.
Source
Thrown at server/raft.go:4367
}
// Make sure to reset commit and applied if above
if n.commit > n.pindex {
n.commit = n.pindex
}
if n.processed > n.commit {
n.processed = n.commit
}
if n.applied > n.processed {
n.applied = n.processed
}
// Refresh bytes count after truncate.
var state StreamState
n.wal.FastState(&state)
n.bytes = state.Bytes
}()
if err := n.wal.Truncate(index); err != nil {
n.warn("Error truncating WAL: %v", err)
n.setWriteErrLocked(err)
return
}
// Set after we know we have truncated properly.
n.pterm, n.pindex = term, index
// Invalidate cached entries the WAL no longer has.
if index == 0 {
n.resetPendingEntries()
} else {
for k, ae := range n.pae {
if k > index {
n.paeBytes -= n.entryStoreSize(ae)
delete(n.pae, k)
}
}
}
View on GitHub (pinned to 3a66a489d2)
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
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at server/raft.go:4367 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/b310899dcdd2250c.
Report an issue: GitHub.