{"record":{"id":"92cb9d13eccaed77","repo":"benbjohnson/litestream","slug":"cannot-validate-saved-txid-for-crash-recovery-w","errorCode":null,"errorMessage":"cannot validate saved TXID for crash recovery: %w","messagePattern":"cannot validate saved TXID for crash recovery: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"replica.go","lineNumber":638,"sourceCode":"\t}\n\n\t// In follow mode, if the database already exists, attempt crash recovery\n\t// by reading the last applied TXID from the sidecar file.\n\tif opt.Follow {\n\t\tif _, statErr := os.Stat(opt.OutputPath); statErr == nil {\n\t\t\ttxid, readErr := ReadTXIDFile(opt.OutputPath)\n\t\t\tif readErr != nil {\n\t\t\t\treturn fmt.Errorf(\"read txid file for crash recovery: %w\", readErr)\n\t\t\t}\n\t\t\tif txid == 0 {\n\t\t\t\treturn fmt.Errorf(\"cannot resume follow mode: database exists but no -txid file found; delete the database to re-restore: %s\", opt.OutputPath)\n\t\t\t}\n\t\t\t// Validate saved TXID is still reachable. If the earliest snapshot\n\t\t\t// starts after our saved TXID, retention has pruned the history\n\t\t\t// and we can't catch up incrementally.\n\t\t\tsnapshotItr, itrErr := r.Client.LTXFiles(ctx, SnapshotLevel, 0, false)\n\t\t\tif itrErr != nil {\n\t\t\t\treturn fmt.Errorf(\"cannot validate saved TXID for crash recovery: %w\", itrErr)\n\t\t\t}\n\n\t\t\tvar latestSnapshot *ltx.FileInfo\n\t\t\tfor snapshotItr.Next() {\n\t\t\t\tlatestSnapshot = snapshotItr.Item()\n\t\t\t}\n\t\t\tif err := snapshotItr.Err(); err != nil {\n\t\t\t\t_ = snapshotItr.Close()\n\t\t\t\treturn fmt.Errorf(\"iterate snapshots for crash recovery validation: %w\", err)\n\t\t\t}\n\t\t\t_ = snapshotItr.Close()\n\n\t\t\tif latestSnapshot != nil {\n\t\t\t\tif latestSnapshot.MinTXID > txid {\n\t\t\t\t\treturn fmt.Errorf(\"cannot resume follow mode: saved TXID %s is behind the earliest snapshot (min TXID %s); replica history has been pruned -- delete %s and %s-txid to re-restore\", txid, latestSnapshot.MinTXID, opt.OutputPath, opt.OutputPath)\n\t\t\t\t}\n\t\t\t\tif txid > latestSnapshot.MaxTXID {\n\t\t\t\t\treturn fmt.Errorf(\"cannot resume follow mode: saved TXID %s is ahead of latest snapshot (max TXID %s); delete %s and %s-txid to re-restore\", txid, latestSnapshot.MaxTXID, opt.OutputPath, opt.OutputPath)","sourceCodeStart":620,"sourceCodeEnd":656,"githubUrl":"https://github.com/benbjohnson/litestream/blob/4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3/replica.go#L620-L656","documentation":"During follow-mode crash recovery, opening the snapshot iterator to validate the saved TXID is still reachable failed. The replica's LTXFiles listing errored — backend connectivity, auth, or listing problem.","triggerScenarios":"Thrown at replica.go:638 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check replica backend connectivity and credentials","Retry starting litestream; the validation re-runs on startup"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3","analyzedAt":"2026-09-06T18:29:25.564Z","contentChangedAt":"2026-09-06T18:29:25.564Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}