nats-io/nats-server · error

Error recreating snapshots directory during reset: %v

Error message

Error recreating snapshots directory during reset: %v

What it means

Recreating the snapshots directory (after it was removed during reset) failed, likely a permission error or a full/unavailable disk. Subsequent snapshot installs may fail until the directory exists again.

Source

Thrown at server/raft.go:2553

	// Drop proposals and inbound entries; they are no longer meaningful
	// against whatever log this node ends up following.
	n.prop.drain()
	n.entry.drain()
	n.resp.drain()
	n.apply.drain()
	n.reqs.drain()
	n.votes.drain()

	// Remove every snapshot under our snapshots dir, not just the one referenced
	// by n.snapfile. Orphans (e.g. from a crash between install and the previous
	// file's removal) would otherwise be picked up by setupLastSnapshot on the
	// next restart and reseed the state we are discarding here.
	snapDir := filepath.Join(n.sd, snapshotsDir)
	if err := os.RemoveAll(snapDir); err != nil {
		n.warn("Error removing snapshots directory during reset: %v", err)
	}
	if err := os.MkdirAll(snapDir, defaultDirPerms); err != nil {
		n.warn("Error recreating snapshots directory during reset: %v", err)
	}
	n.snapfile = _EMPTY_

	// Abort any inflight async snapshot checkpoint.
	n.snapshotting = false

	// Reset the WAL, but reset these first to not trip the assertion.
	n.commit, n.hcommit, n.applied, n.processed, n.papplied = 0, 0, 0, 0, 0
	n.resetWAL()

	// Reset peer set to just ourselves; a new leader will fold us back into
	// the cluster's membership view via processPeerState.
	n.peers = map[string]*lps{n.id: {time.Time{}, 0}}
	n.removed = nil
	n.adjustClusterSizeAndQuorum()

	n.term, n.vote = 0, _EMPTY_
	n.writeTermVote()

View on GitHub (pinned to 3a66a489d2)

Solutions

  1. Verify the store directory permissions and that the parent path exists
  2. Check disk space and mount health
  3. Create the directory manually with correct ownership and restart the node
Defensive patterns

Strategy: fallback

When it happens

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