nats-io/nats-server · error

Got error on apply commit during replay: %v

Error message

Got error on apply commit during replay: %v

What it means

A warning logged by ResumeApply() when applyCommit() fails while replaying committed-but-unapplied entries during a catch-up. The replay loop breaks on the first error, leaving the node's applied index short of its committed index; this usually indicates WAL read/decode problems for that entry.

Source

Thrown at server/raft.go:1429

func (n *raft) ResumeApply() {
	n.Lock()
	defer n.Unlock()

	if !n.paused {
		return
	}

	n.debug("Resuming our apply channel")

	// Reset before we start.
	n.resetElectionTimeout()

	// Run catchup..
	if n.hcommit > n.commit {
		n.debug("Resuming %d replays", n.hcommit+1-n.commit)
		for index := n.commit + 1; index <= n.hcommit; index++ {
			if err := n.applyCommit(index); err != nil {
				n.warn("Got error on apply commit during replay: %v", err)
				break
			}
			// We want to unlock here to allow the upper layers to call Applied() without blocking.
			n.Unlock()
			// Give hint to let other Go routines run.
			// Might not be necessary but seems to make it more fine grained interleaving.
			runtime.Gosched()
			// Simply re-acquire
			n.Lock()
			// Need to check if we got closed.
			if n.State() == Closed {
				return
			}
		}
	}

	// Clear our paused state after we apply.
	n.paused = false

View on GitHub (pinned to 3a66a489d2)

Solutions

  1. Inspect the wrapped applyCommit error for WAL corruption at the failing index
  2. Restore the WAL or catch up from a peer snapshot/entries
  3. Call ResumeApply() again after fixing storage issues to continue replay
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at server/raft.go:1429 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/44ca3aea51661790. Report an issue: GitHub.