{"record":{"id":"671df25bd69a3757","repo":"benbjohnson/litestream","slug":"cannot-calc-restore-plan-w-671df2","errorCode":null,"errorMessage":"cannot calc restore plan: %w","messagePattern":"cannot calc restore plan: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"vfs.go","lineNumber":1258,"sourceCode":"\t}\n\n\t// Start compaction monitors if enabled\n\tif f.compactor != nil && f.vfs != nil {\n\t\tf.startCompactionMonitors()\n\t}\n\n\treturn nil\n}\n\n// SetTargetTime rebuilds the page index to view the database at a specific time.\nfunc (f *VFSFile) SetTargetTime(ctx context.Context, timestamp time.Time) error {\n\tif timestamp.IsZero() {\n\t\treturn fmt.Errorf(\"target time required\")\n\t}\n\n\tinfos, err := CalcRestorePlan(ctx, f.client, 0, timestamp, f.logger)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"cannot calc restore plan: %w\", err)\n\t} else if len(infos) == 0 {\n\t\treturn fmt.Errorf(\"no backup files available\")\n\t}\n\n\t// Disable hydrated reads during time travel - hydrated file is at latest state\n\tif f.hydrator != nil && f.hydrator.Complete() {\n\t\tf.hydrator.Disable()\n\t\tf.logger.Debug(\"hydration disabled for time travel\", \"target\", timestamp)\n\t}\n\n\treturn f.rebuildIndex(ctx, infos, &timestamp)\n}\n\n// ResetTime rebuilds the page index to the latest available state.\nfunc (f *VFSFile) ResetTime(ctx context.Context) error {\n\tinfos, err := CalcRestorePlan(ctx, f.client, 0, time.Time{}, f.logger)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"cannot calc restore plan: %w\", err)","sourceCodeStart":1240,"sourceCodeEnd":1276,"githubUrl":"https://github.com/benbjohnson/litestream/blob/4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3/vfs.go#L1240-L1276","documentation":"Returned by VFSFile.SetTargetTime when CalcRestorePlan cannot compute a valid sequence of LTX files reaching the requested timestamp. CalcRestorePlan walks the replica's file infos to find the snapshot+ generación of WAL-level LTX files covering the target time; planning errors mean the replica listing or metadata could not be turned into a restore plan.","triggerScenarios":"CalcRestorePlan returns an error for a given timestamp — LTX listing fails, LTX file metadata is inconsistent/corrupt, timestamps in infos overlap or are malformed, or the replica client errors during listing.","commonSituations":"Time-travel target predates the earliest snapshot or sits in a gap caused by deleted/compacted LTX files; corrupt LTX metadata in the bucket; replica listing failures (permissions, network).","solutions":["Choose a timestamp within the replica's covered range (after the earliest available snapshot)","Verify LTX file metadata integrity with litestream ltx and re-replicate if corrupt","Check replica storage connectivity/permissions so listing succeeds","Retry on transient listing errors"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"infos, _ := client.LTXInfos(ctx)\nminT := earliestTimestamp(infos)\nif targetTime.Before(minT) { return fmt.Errorf(\"target %v predates earliest snapshot %v\", targetTime, minT) }","typeGuard":"func targetCovered(t time.Time, minT time.Time) bool { return !t.Before(minT) }","tryCatchPattern":"if err := file.SetTargetTime(ctx, t); err != nil {\n    if strings.Contains(err.Error(), \"cannot calc restore plan\") {\n        return fmt.Errorf(\"no LTX coverage for %v: %w\", t, err)\n    }\n    return err\n}","preventionTips":["Discover the replica's earliest snapshot time before time-traveling","Validate LTX metadata integrity periodically","Handle retention: don't assume old timestamps are restorable"],"tags":["time-travel","restore-plan","ltx"],"backgroundTag":"empty-result-set","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"}