nats-io/nats-server · error

Resetting WAL state

Error message

Resetting WAL state

What it means

truncateWAL was asked to reset to term 0/index 0 while the node had commits (commit > 0) — i.e. the entire WAL state is being discarded rather than merely cleared when empty. Logged at warn because it means committed history on this node is being thrown away in favor of re-following a leader.

Source

Thrown at server/raft.go:4326

}

// Lock should be held.
func (n *raft) cancelCatchupSignal() {
	if n.catchup == nil || !n.catchup.signal {
		return
	}
	// Send nil entry to signal the upper layers we are done catching up.
	n.apply.push(nil)
}

// Truncate our WAL and reset.
// Lock should be held.
func (n *raft) truncateWAL(term, index uint64) {
	n.debug("Truncating and repairing WAL to Term %d Index %d", term, index)

	if term == 0 && index == 0 {
		if n.commit > 0 {
			n.warn("Resetting WAL state")
		} else {
			n.debug("Clearing WAL state (no commits)")
		}
	}
	if index < n.commit {
		assert.Unreachable("WAL truncate lost commits", map[string]any{
			"n.accName": n.accName,
			"n.group":   n.group,
			"n.id":      n.id,
			"term":      term,
			"index":     index,
			"commit":    n.commit,
			"applied":   n.applied,
		})
	}

	defer func() {
		// Check to see if we invalidated any snapshots that might have held state

View on GitHub (pinned to 3a66a489d2)

Solutions

  1. Expected during reset/conflict recovery flows; the node re-syncs from the leader
  2. Ensure at least one healthy peer retains the data before resets
  3. Investigate if resets happen outside deliberate recovery operations
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at server/raft.go:4326 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/532bc504e8657b9f. Report an issue: GitHub.