{"record":{"id":"780798d48de76c66","repo":"nats-io/nats-server","slug":"couldn-t-load-next-message-after-seq-d-s","errorCode":null,"errorMessage":"couldn't load next message after seq %d: %s","messagePattern":"couldn't load next message after seq (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/stream_backup.go","lineNumber":229,"sourceCode":"\t\t\t\t}\n\t\t\t\tif err := writeConsumerMsg(SnapshotConsumerState{\n\t\t\t\t\tConsumerConfig: config,\n\t\t\t\t\tConsumerState:  state,\n\t\t\t\t}); err != nil {\n\t\t\t\t\terrCh <- err\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tvar sm StoreMsg\n\tfor seq := state.FirstSeq - 1; seq < state.LastSeq; {\n\t\tif _, seq, err = store.LoadNextMsg(fwcs, true, seq+1, &sm); err != nil {\n\t\t\tif err == ErrStoreEOF {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\terrCh <- fmt.Errorf(\"couldn't load next message after seq %d: %s\", seq+1, err)\n\t\t\treturn\n\t\t}\n\t\tif err = writeStoreMsg(&sm); err != nil {\n\t\t\terrCh <- err\n\t\t\treturn\n\t\t}\n\t}\n\n\t// End of backup sentinel. A clear marker makes it obvious when\n\t// a backup has been truncated or not without having to count\n\t// messages or from first/last sequence, which may not be possible\n\t// during the rewrite of a large stream backup.\n\tif err = writeGeneric(_EMPTY_, 0, 0, 0, 0, nil); err != nil {\n\t\terrCh <- err\n\t}\n}\n\n// RestoreStreamSnapshotV2 will restore a stream from a snapshot.","sourceCodeStart":211,"sourceCodeEnd":247,"githubUrl":"https://github.com/nats-io/nats-server/blob/3a66a489d262bf89b71a71c955c94920394532f3/server/stream_backup.go#L211-L247","documentation":"Emitted while the snapshot iterates stream messages via store.LoadNextMsg. After filtering out the normal ErrStoreEOF end-of-stream sentinel, any remaining error from the message store (I/O failure, index corruption, purged/missing sequence) is reported with the sequence where iteration stopped, terminating the backup.","triggerScenarios":"Thrown at server/stream_backup.go:229 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check server logs for file-store errors (disk failures, corrupted indexes) around the reported sequence","Run store consistency checks or rebuild the stream from replicas/backup","Free disk space and re-attempt the backup once the underlying store error is resolved"],"exampleFix":null,"handlingStrategy":"try-catch","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"}