{"record":{"id":"838525bc55bd69ab","repo":"benbjohnson/litestream","slug":"cannot-resume-follow-mode-saved-txid-s-is-behind","errorCode":null,"errorMessage":"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","messagePattern":"cannot resume follow mode: saved TXID (.+?) is behind the earliest snapshot \\(min TXID (.+?)\\); replica history has been pruned -- delete (.+?) and (.+?)-txid to re-restore","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"replica.go","lineNumber":653,"sourceCode":"\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)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tr.Logger().Info(\"resuming follow mode from crash recovery\", \"txid\", txid, \"output\", opt.OutputPath)\n\t\t\treturn r.follow(ctx, opt.OutputPath, txid, opt.FollowInterval)\n\t\t}\n\t}\n\n\t// Ensure output path does not already exist.\n\tif _, err := os.Stat(opt.OutputPath); err == nil {\n\t\treturn fmt.Errorf(\"cannot restore, output path already exists: %s\", opt.OutputPath)\n\t} else if !os.IsNotExist(err) {\n\t\treturn err\n\t}\n","sourceCodeStart":635,"sourceCodeEnd":671,"githubUrl":"https://github.com/benbjohnson/litestream/blob/4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3/replica.go#L635-L671","documentation":"Error \"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\" thrown in benbjohnson/litestream.","triggerScenarios":"Thrown at replica.go:653 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Delete the output database and its -txid sidecar, then re-restore from the latest snapshot","Extend retention or shorten downtime windows so snapshots needed for catch-up are not pruned"],"exampleFix":null,"handlingStrategy":"validation","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-14T00:17:10.932Z"}