{"record":{"id":"e84af257d503c337","repo":"nats-io/nats-server","slug":"sourcing-state-is-outdated-attempting-to-recover","errorCode":null,"errorMessage":"Sourcing state is outdated; attempting to recover using linear scan (seq %d to %d)","messagePattern":"Sourcing state is outdated; attempting to recover using linear scan \\(seq (.+?) to (.+?)\\)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/filestore.go","lineNumber":2352,"sourceCode":"\tif sourcesRecover && !ttlRecover && !schedRecover {\n\t\tif fs.state.Msgs > 0 && sourcesSeq <= fs.state.LastSeq {\n\t\t\tfs.warn(\"Sourcing state is outdated; attempting to recover using backward scan (seq %d to %d)\", sourcesSeq, fs.state.LastSeq)\n\t\t\tif err := fs.recoverSourcesBackwardScan(sourcesSeq, sourcesScan); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t\treturn nil\n\t}\n\n\tif fs.state.Msgs > 0 && scanSeq <= fs.state.LastSeq {\n\t\tif ttlRecover && ttlSeq <= fs.state.LastSeq {\n\t\t\tfs.warn(\"TTL state is outdated; attempting to recover using linear scan (seq %d to %d)\", ttlSeq, fs.state.LastSeq)\n\t\t}\n\t\tif schedRecover && schedSeq <= fs.state.LastSeq {\n\t\t\tfs.warn(\"Message scheduling state is outdated; attempting to recover using linear scan (seq %d to %d)\", schedSeq, fs.state.LastSeq)\n\t\t}\n\t\tif sourcesRecover && sourcesSeq <= fs.state.LastSeq {\n\t\t\tfs.warn(\"Sourcing state is outdated; attempting to recover using linear scan (seq %d to %d)\", sourcesSeq, fs.state.LastSeq)\n\t\t}\n\t\t// Only consider sources that need recovering.\n\t\tupdate := func(iName string, sseq uint64, ident string) {\n\t\t\tif _, ok := sourcesScan[iName]; !ok {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif sss, ok := fs.sources[iName]; ok {\n\t\t\t\tsss.Seq, sss.Ident = sseq, ident\n\t\t\t}\n\t\t}\n\t\tvar (\n\t\t\tmb     *msgBlock\n\t\t\tsm     StoreMsg\n\t\t\tmblseq uint64\n\t\t)\n\t\tfor seq := scanSeq; seq <= fs.state.LastSeq; seq++ {\n\t\tretry:\n\t\t\tif mb == nil {","sourceCodeStart":2334,"sourceCodeEnd":2370,"githubUrl":"https://github.com/nats-io/nats-server/blob/3a66a489d262bf89b71a71c955c94920394532f3/server/filestore.go#L2334-L2370","documentation":"On recovery, the per-source (mirror/import) tracking state is outdated relative to the stored messages. The store re-derives it by scanning the message range so source dedup/continuity decisions remain correct.","triggerScenarios":"Thrown at server/filestore.go:2352 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["No action needed; the recovery scan repairs source state","For source-only staleness a faster backward scan is used automatically","Ensure clean shutdowns to minimize recovery scans"],"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"}