nats-io/nats-server · error

Wrong index, ae is %+v, index stored was %d, n.pindex is %d,

Error message

Wrong index, ae is %+v, index stored was %d, n.pindex is %d, will reset

What it means

After StoreMsg, the WAL-assigned sequence does not equal ae.pindex+1 — the log's physical sequence and the entry chain have diverged (indicates WAL inconsistency or a bug). As a defensive measure the node steps down if leader and resets so state is re-derived from a consistent point.

Source

Thrown at server/raft.go:5070

// Store our append entry to our WAL.
// lock should be held.
func (n *raft) storeToWAL(ae *appendEntry) error {
	if ae == nil {
		return fmt.Errorf("raft: Missing append entry for storage")
	}
	if n.werr != nil {
		return n.werr
	}

	seq, _, err := n.wal.StoreMsg(_EMPTY_, nil, ae.buf, 0)
	if err != nil {
		n.setWriteErrLocked(err)
		return err
	}

	// Sanity checking for now.
	if index := ae.pindex + 1; index != seq {
		n.warn("Wrong index, ae is %+v, index stored was %d, n.pindex is %d, will reset", ae, seq, n.pindex)
		if n.State() == Leader {
			n.stepdownLocked(n.selectNextLeader())
		}
		// Reset and cancel any catchup.
		n.resetWAL()
		n.cancelCatchup()
		return errEntryStoreFailed
	}

	n.bytes += n.entryStoreSize(ae)
	n.pterm = ae.term
	n.pindex = seq
	return nil
}

const (
	pauseQuorumThreshold = 100_000
	pauseQuorumBytes     = 1 * 1024 * 1024 * 1024 // 1GB

View on GitHub (pinned to 3a66a489d2)

Solutions

  1. Treat as corruption: allow the reset/re-sync to repair the WAL
  2. Check storage health for the root cause of sequence divergence
  3. Report with logs if it reproduces on healthy disks — it marks a serious invariant break
Defensive patterns

Strategy: fallback

When it happens

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