{"record":{"id":"2742c014dbf65b91","repo":"benbjohnson/litestream","slug":"cannot-determine-l-d-max-ltx-file-for-q-w","errorCode":null,"errorMessage":"cannot determine L%d max ltx file for %q: %w","messagePattern":"cannot determine L(.+?) max ltx file for %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"db.go","lineNumber":3288,"sourceCode":"\t\treturn 0, exec.pos, err\n\t}\n\treturn h.Sum64(), exec.pos, nil\n}\n\n// MaxLTXFileInfo returns the metadata for the last LTX file in a level.\n// If cached, it will returned the local copy. Otherwise, it fetches from the replica.\nfunc (db *DB) MaxLTXFileInfo(ctx context.Context, level int) (ltx.FileInfo, error) {\n\tdb.maxLTXFileInfos.Lock()\n\tdefer db.maxLTXFileInfos.Unlock()\n\n\tinfo, ok := db.maxLTXFileInfos.m[level]\n\tif ok {\n\t\treturn *info, nil\n\t}\n\n\tremoteInfo, err := db.Replica.MaxLTXFileInfo(ctx, level)\n\tif err != nil {\n\t\treturn ltx.FileInfo{}, fmt.Errorf(\"cannot determine L%d max ltx file for %q: %w\", level, db.Path(), err)\n\t}\n\n\tdb.maxLTXFileInfos.m[level] = &remoteInfo\n\treturn remoteInfo, nil\n}\n\n// DefaultRestoreParallelism is the default parallelism when downloading WAL files.\nconst DefaultRestoreParallelism = 8\n\n// DefaultFollowInterval is the default polling interval for follow mode.\nconst DefaultFollowInterval = 1 * time.Second\n\n// IntegrityCheckMode specifies the level of integrity checking after restore.\ntype IntegrityCheckMode int\n\nconst (\n\tIntegrityCheckNone IntegrityCheckMode = iota\n\tIntegrityCheckQuick","sourceCodeStart":3270,"sourceCodeEnd":3306,"githubUrl":"https://github.com/benbjohnson/litestream/blob/4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3/db.go#L3270-L3306","documentation":"Wraps a failure from Replica.MaxLTXFileInfo when determining the maximum LTX file at a given level for the database, used to populate the maxLTXFileInfos cache. It is thrown when neither cached nor locally-known info exists and the remote max-file lookup fails.","triggerScenarios":"Operations needing the latest remote LTX file at a level (restore position checks, compaction decisions) when MaxLTXFileInfo's listing fails: storage outage, auth failure, or an unreachable/misnamed bucket (db.go:3288).","commonSituations":"First sync against a freshly configured replica with wrong credentials; network partition during compaction; typo'd bucket or path in the config.","solutions":["Check the wrapped inner error to separate auth, network, and not-found causes.","Verify the replica URL (bucket, path, region/endpoint) in the litestream config.","Confirm credentials have ListBucket/Get permissions on the prefix.","Retry after transient failures; the lookup is read-only and cached on success.","If the bucket is intentionally empty, ensure the caller tolerates a zero TXID rather than erroring."],"exampleFix":"// before\nremoteInfo, err := db.Replica.MaxLTXFileInfo(ctx, level)\nif err != nil { return ltx.FileInfo{}, fmt.Errorf(\"cannot determine L%d max ltx file for %q: %w\", level, db.Path(), err) }\n// after (pre-flight init)\nif err := db.Replica.Client.Init(ctx); err != nil { return ltx.FileInfo{}, fmt.Errorf(\"init replica: %w\", err) }\nremoteInfo, err := db.Replica.MaxLTXFileInfo(ctx, level)\nif err != nil { return ltx.FileInfo{}, fmt.Errorf(\"cannot determine L%d max ltx file for %q: %w\", level, db.Path(), err) }","handlingStrategy":"retry","validationCode":"if err := db.Replica.Client.Init(ctx); err != nil { return fmt.Errorf(\"replica init failed: %w\", err) }","typeGuard":null,"tryCatchPattern":"info, err := db.Replica.MaxLTXFileInfo(ctx, level)\nif err != nil {\n    if isTransient(err) { return retryWithBackoff(ctx) }\n    return fmt.Errorf(\"cannot determine L%d max ltx file: %w\", level, err)\n}","preventionTips":["Verify the replica URL before first sync.","Ensure list/get permissions on the bucket prefix.","Handle the empty-bucket case explicitly instead of treating it as failure."],"tags":["storage","lookup","replication","network"],"backgroundTag":"resource-not-found","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"}