{"record":{"id":"5a14fb29201171b2","repo":"nats-io/nats-server","slug":"message-scheduling-state-is-outdated-attempting-t","errorCode":null,"errorMessage":"Message scheduling state is outdated; attempting to recover using linear scan (seq %d to %d)","messagePattern":"Message scheduling state is outdated; attempting to recover using linear scan \\(seq (.+?) to (.+?)\\)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/filestore.go","lineNumber":2349,"sourceCode":"\t}\n\n\t// If only sources need recovering, then we can optimize to a backward scan.\n\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)","sourceCodeStart":2331,"sourceCodeEnd":2367,"githubUrl":"https://github.com/nats-io/nats-server/blob/3a66a489d262bf89b71a71c955c94920394532f3/server/filestore.go#L2331-L2367","documentation":"On recovery, the message-scheduling state (e.g. for delayed/paused message delivery) is outdated relative to the stored messages. The store will re-derive scheduling via a linear scan of the message range rather than trusting the stale state file.","triggerScenarios":"Thrown at server/filestore.go:2349 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["No action needed; the scan rebuilds scheduling state automatically","Avoid unclean shutdowns which leave state files stale","Expect a one-time startup cost on large streams"],"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"}