{"record":{"id":"e8720c287b0e2343","repo":"benbjohnson/litestream","slug":"find-ltx-snapshot-w","errorCode":null,"errorMessage":"find LTX snapshot: %w","messagePattern":"find LTX snapshot: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"replica.go","lineNumber":1434,"sourceCode":"\t}\n\n\t// If no LTX backups exist, use v0.3.x.\n\tif ltxUpdatedAt.IsZero() {\n\t\tr.Logger().Debug(\"using v0.3.x restore (no LTX backups)\")\n\t\treturn true, nil\n\t}\n\n\t// Both formats have backups - compare based on timestamp or latest.\n\tif !timestamp.IsZero() {\n\t\t// With timestamp: use format with best snapshot before timestamp.\n\t\tv3Snapshot, err := r.findBestV3SnapshotForTimestamp(ctx, client, timestamp)\n\t\tif err != nil {\n\t\t\treturn false, fmt.Errorf(\"find v0.3.x snapshot: %w\", err)\n\t\t}\n\n\t\tltxSnapshot, err := r.findBestLTXSnapshotForTimestamp(ctx, timestamp)\n\t\tif err != nil {\n\t\t\treturn false, fmt.Errorf(\"find LTX snapshot: %w\", err)\n\t\t}\n\n\t\tif v3Snapshot != nil && (ltxSnapshot == nil || v3Snapshot.CreatedAt.After(ltxSnapshot.CreatedAt)) {\n\t\t\tr.Logger().Debug(\"using v0.3.x restore (better snapshot for timestamp)\",\n\t\t\t\t\"v3_snapshot\", v3Snapshot.CreatedAt,\n\t\t\t\t\"ltx_snapshot\", ltxSnapshot)\n\t\t\treturn true, nil\n\t\t}\n\t} else {\n\t\t// Without timestamp: use format with most recent backup.\n\t\tif v3UpdatedAt.After(ltxUpdatedAt) {\n\t\t\tr.Logger().Debug(\"using v0.3.x restore (more recent backup)\",\n\t\t\t\t\"v3_updated_at\", v3UpdatedAt,\n\t\t\t\t\"ltx_updated_at\", ltxUpdatedAt)\n\t\t\treturn true, nil\n\t\t}\n\t}\n","sourceCodeStart":1416,"sourceCodeEnd":1452,"githubUrl":"https://github.com/benbjohnson/litestream/blob/4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3/replica.go#L1416-L1452","documentation":"Wraps an error from findBestLTXSnapshotForTimestamp during timestamp-based restore format selection. Listing LTX snapshot-level files (level-sorted, filtered by CreatedAt < timestamp) failed, so Litestream cannot compare LTX against the v0.3.x candidate.","triggerScenarios":"Restore -timestamp with both formats present and FindLTXFiles on SnapshotLevel fails: storage backend error while listing snapshot LTX files, or the filter callback's enumeration hitting a corrupt/unreadable object.","commonSituations":"Lifecycle policies deleting snapshot LTX files mid-restore; IAM missing read permission on snapshot prefixes; transient object-store 5xx errors.","solutions":["Inspect the wrapped cause; verify read permissions on snapshot-level LTX prefixes.","Retry the restore if transient.","Check that lifecycle/retention rules are not deleting snapshot files before your PITR window (disable retention only when a cloud lifecycle policy owns cleanup).","Restore latest without -timestamp to skip the snapshot filter."],"exampleFix":"// before\nltxSnapshot, err := r.findBestLTXSnapshotForTimestamp(ctx, timestamp)\n// after\n// ensure snapshot LTX files exist and are readable:\n// $ litestream ltx -level 4 <replica>   // inspect levels\n// then retry the timestamped restore\nltxSnapshot, err := r.findBestLTXSnapshotForTimestamp(ctx, timestamp)","handlingStrategy":"validation","validationCode":"// Go: check snapshot-level files exist before a timestamped restore\ninfos, err := FindLTXFiles(ctx, client, SnapshotLevel, true, nil)\nif err != nil || len(infos) == 0 {\n    return fmt.Errorf(\"no restorable LTX snapshots found\")\n}","typeGuard":null,"tryCatchPattern":"if err != nil {\n    if strings.Contains(err.Error(), \"find LTX snapshot\") {\n        // verify snapshot prefixes readable; retry or restore latest\n    }\n    return err\n}","preventionTips":["Ensure IAM allows reading snapshot-level LTX prefixes.","Verify PITR window with `litestream ltx -level all` before relying on -timestamp.","Keep retention windows aligned with your PITR requirements."],"tags":["restore","ltx","snapshot-selection","pitr"],"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"}