{"record":{"id":"b33a66322388f520","repo":"nats-io/nats-server","slug":"recovering-sources-state-from-index-errored-v","errorCode":null,"errorMessage":"Recovering sources state from index errored: %v","messagePattern":"Recovering sources state from index errored: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/filestore.go","lineNumber":12480,"sourceCode":"\t\tbuf = binary.AppendUvarint(buf, ss.Seq)\n\t\tbuf = binary.AppendUvarint(buf, uint64(len(ss.Ident)))\n\t\tbuf = append(buf, ss.Ident...)\n\t}\n\tfs.mu.RUnlock()\n\n\treturn fs.writeFileWithOptionalSync(fn, buf, defaultFilePerms)\n}\n\n// Lock should be held.\nfunc (fs *fileStore) recoverSourcesState() uint64 {\n\t// See if we have a sources index file.\n\tfs.dios.acquire()\n\tfn := fs.sourcesStatePath()\n\tbuf, err := os.ReadFile(fn)\n\tfs.dios.release()\n\n\tif err != nil && !os.IsNotExist(err) {\n\t\tfs.warn(\"Recovering sources state from index errored: %v\", err)\n\t}\n\n\tvar sourcesSeq uint64\n\tif err == nil {\n\t\tsourcesSeq, err = fs.decodeSourcesState(buf)\n\t\tif err != nil {\n\t\t\tfs.warn(\"Error decoding sources state: %s\", err)\n\t\t\t// Remove the file, and reset collected state (if any).\n\t\t\t_ = os.Remove(fn)\n\t\t\tfs.sources = nil\n\t\t}\n\t}\n\n\tif sourcesSeq < fs.state.FirstSeq {\n\t\tsourcesSeq = fs.state.FirstSeq\n\t}\n\treturn sourcesSeq\n}","sourceCodeStart":12462,"sourceCodeEnd":12498,"githubUrl":"https://github.com/nats-io/nats-server/blob/3a66a489d262bf89b71a71c955c94920394532f3/server/filestore.go#L12462-L12498","documentation":"A warning logged by recoverSourcesState() during stream recovery when reading the sources index file fails with an error other than not-exist (I/O or permission problem). Recovery proceeds without the persisted sources state, which is rebuilt in memory; mirror/source sequence continuity may be affected.","triggerScenarios":"Thrown at server/filestore.go:12480 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the wrapped OS error for permission or disk problems in the store directory","Repair I/O issues and restart to recover sources state properly","If the index file is corrupt, remove it and let the state rebuild"],"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-08T15:18:49.778Z"}