{"record":{"id":"d6d510df3f06e246","repo":"benbjohnson/litestream","slug":"fetch-ltx-files-w-d6d510","errorCode":null,"errorMessage":"fetch ltx files: %w","messagePattern":"fetch ltx files: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"db.go","lineNumber":2959,"sourceCode":"\tif err != nil {\n\t\treturn info, err\n\t}\n\n\tdb.maxLTXFileInfos.Lock()\n\tdb.maxLTXFileInfos.m[SnapshotLevel] = info\n\tdb.maxLTXFileInfos.Unlock()\n\n\treturn info, nil\n}\n\n// EnforceSnapshotRetention enforces retention of the snapshot level in the database by timestamp.\nfunc (db *DB) EnforceSnapshotRetention(ctx context.Context, timestamp time.Time) (minSnapshotTXID ltx.TXID, err error) {\n\tdb.Logger.Debug(\"enforcing snapshot retention\", \"timestamp\", timestamp)\n\n\t// Normal operation - use fast timestamps\n\titr, err := db.Replica.Client.LTXFiles(ctx, SnapshotLevel, 0, false)\n\tif err != nil {\n\t\treturn 0, fmt.Errorf(\"fetch ltx files: %w\", err)\n\t}\n\tdefer itr.Close()\n\n\tvar deleted []*ltx.FileInfo\n\tvar snapshots []*ltx.FileInfo\n\tvar lastInfo *ltx.FileInfo\n\tfor itr.Next() {\n\t\tinfo := itr.Item()\n\t\tsnapshots = append(snapshots, info)\n\t\tlastInfo = info\n\n\t\t// If this snapshot is before the retention timestamp, mark it for deletion.\n\t\tif info.CreatedAt.Before(timestamp) {\n\t\t\tdeleted = append(deleted, info)\n\t\t\tcontinue\n\t\t}\n\t}\n","sourceCodeStart":2941,"sourceCodeEnd":2977,"githubUrl":"https://github.com/benbjohnson/litestream/blob/4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3/db.go#L2941-L2977","documentation":"Wraps a failure from Replica.Client.LTXFiles when listing remote LTX files at the snapshot level inside DB.EnforceSnapshotRetention. Retention enforcement cannot proceed without enumerating existing snapshot files, so the underlying storage error is propagated with context. It indicates a remote replica listing failure, not a local database problem.","triggerScenarios":"Calling EnforceSnapshotRetention when the replica client's LTXFiles listing fails: network outage to S3/GS/Azure, expired credentials, wrong bucket/container, or a storage backend 5xx/throttle during snapshot-level listing.","commonSituations":"A scheduled retention run while the object store is unreachable or credentials were rotated; misconfigured replica URL pointing at a nonexistent bucket; S3 SlowDown throttling during bulk listing.","solutions":["Verify replica connectivity and credentials (aws s3 ls / gsutil ls on the bucket path).","Check litestream logs for the wrapped inner error (AccessDenied, NoSuchBucket) and fix the storage config.","Retry after transient network issues; the listing is read-only and idempotent.","In a custom ReplicaClient, ensure LTXFiles surfaces real errors instead of empty iterations.","Confirm the replica URL scheme/host/path in the config are correct."],"exampleFix":"// before\nitr, err := db.Replica.Client.LTXFiles(ctx, SnapshotLevel, 0, false)\nif err != nil { return 0, fmt.Errorf(\"fetch ltx files: %w\", err) }\n// after (caller-side guard)\nif err := db.Replica.Client.Init(ctx); err != nil { return fmt.Errorf(\"init replica: %w\", err) }\nitr, err := db.Replica.Client.LTXFiles(ctx, SnapshotLevel, 0, false)\nif err != nil { return 0, fmt.Errorf(\"fetch ltx files: %w\", err) }","handlingStrategy":"retry","validationCode":"if err := db.Replica.Client.Init(ctx); err != nil { return fmt.Errorf(\"replica init failed: %w\", err) }","typeGuard":null,"tryCatchPattern":"itr, err := db.Replica.Client.LTXFiles(ctx, SnapshotLevel, 0, false)\nif err != nil {\n    if isTransient(err) { return retryWithBackoff(ctx) }\n    return fmt.Errorf(\"fetch ltx files: %w\", err)\n}","preventionTips":["Monitor bucket reachability and credential expiry before retention cycles.","Alert on wrapped inner storage errors (AccessDenied, NoSuchBucket, Throttling).","Configure SDK-level retries for transient 5xx."],"tags":["storage","replication","retention","network"],"backgroundTag":"api-request-failed","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"}