{"record":{"id":"1839ca409b319b3a","repo":"nats-io/nats-server","slug":"error-recreating-snapshots-directory-during-reset","errorCode":null,"errorMessage":"Error recreating snapshots directory during reset: %v","messagePattern":"Error recreating snapshots directory during reset: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/raft.go","lineNumber":2553,"sourceCode":"\t// Drop proposals and inbound entries; they are no longer meaningful\n\t// against whatever log this node ends up following.\n\tn.prop.drain()\n\tn.entry.drain()\n\tn.resp.drain()\n\tn.apply.drain()\n\tn.reqs.drain()\n\tn.votes.drain()\n\n\t// Remove every snapshot under our snapshots dir, not just the one referenced\n\t// by n.snapfile. Orphans (e.g. from a crash between install and the previous\n\t// file's removal) would otherwise be picked up by setupLastSnapshot on the\n\t// next restart and reseed the state we are discarding here.\n\tsnapDir := filepath.Join(n.sd, snapshotsDir)\n\tif err := os.RemoveAll(snapDir); err != nil {\n\t\tn.warn(\"Error removing snapshots directory during reset: %v\", err)\n\t}\n\tif err := os.MkdirAll(snapDir, defaultDirPerms); err != nil {\n\t\tn.warn(\"Error recreating snapshots directory during reset: %v\", err)\n\t}\n\tn.snapfile = _EMPTY_\n\n\t// Abort any inflight async snapshot checkpoint.\n\tn.snapshotting = false\n\n\t// Reset the WAL, but reset these first to not trip the assertion.\n\tn.commit, n.hcommit, n.applied, n.processed, n.papplied = 0, 0, 0, 0, 0\n\tn.resetWAL()\n\n\t// Reset peer set to just ourselves; a new leader will fold us back into\n\t// the cluster's membership view via processPeerState.\n\tn.peers = map[string]*lps{n.id: {time.Time{}, 0}}\n\tn.removed = nil\n\tn.adjustClusterSizeAndQuorum()\n\n\tn.term, n.vote = 0, _EMPTY_\n\tn.writeTermVote()","sourceCodeStart":2535,"sourceCodeEnd":2571,"githubUrl":"https://github.com/nats-io/nats-server/blob/3a66a489d262bf89b71a71c955c94920394532f3/server/raft.go#L2535-L2571","documentation":"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.","triggerScenarios":"Thrown at server/raft.go:2553 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the store directory permissions and that the parent path exists","Check disk space and mount health","Create the directory manually with correct ownership and restart the node"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"3a66a489d262bf89b71a71c955c94920394532f3","analyzedAt":"2026-09-02T04:41:54.247Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}