{"record":{"id":"e8cf6e85e7f31535","repo":"benbjohnson/litestream","slug":"fetch-src-level-info-w","errorCode":null,"errorMessage":"fetch src level info: %w","messagePattern":"fetch src level info: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"store.go","lineNumber":808,"sourceCode":"\t\t\treturn nil, fmt.Errorf(\"fetch db position: %w\", err)\n\t\t}\n\t\tif dstInfo.MaxTXID != 0 && dstInfo.MaxTXID >= pos.TXID {\n\t\t\treturn nil, ErrNoCompaction\n\t\t}\n\n\t\tinfo, err := db.Snapshot(ctx)\n\t\tif err != nil {\n\t\t\treturn info, err\n\t\t}\n\t\tdb.Logger.InfoContext(ctx, \"snapshot complete\", \"txid\", info.MaxTXID.String(), \"size\", info.Size)\n\t\treturn info, nil\n\t}\n\n\t// Fetch latest LTX files for both the source & destination so we can see if we need to make progress.\n\tsrcLevel := s.levels.PrevLevel(dstLevel)\n\tsrcInfo, err := db.MaxLTXFileInfo(ctx, srcLevel)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"fetch src level info: %w\", err)\n\t}\n\n\t// Skip if there are no new files to compact.\n\tif srcInfo.MaxTXID <= dstInfo.MinTXID {\n\t\treturn nil, ErrNoCompaction\n\t}\n\n\tinfo, err := db.Compact(ctx, dstLevel)\n\tif err != nil {\n\t\treturn info, err\n\t}\n\n\tdb.Logger.InfoContext(ctx, \"compaction complete\",\n\t\t\"level\", dstLevel,\n\t\tslog.Group(\"txid\",\n\t\t\t\"min\", info.MinTXID.String(),\n\t\t\t\"max\", info.MaxTXID.String(),\n\t\t),","sourceCodeStart":790,"sourceCodeEnd":826,"githubUrl":"https://github.com/benbjohnson/litestream/blob/4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3/store.go#L790-L826","documentation":"Store.CompactDB failed fetching metadata about the newest LTX file at the source level (the level immediately below the destination) via db.MaxLTXFileInfo(ctx, srcLevel). Like the dst fetch, this enumerates LTX files on the replica storage, so errors are usually backend/network problems. The wrapped error is returned with %w.","triggerScenarios":"CompactDB(ctx, db, dstLevel) where PrevLevel(dstLevel) lookup metadata fails: LTXFiles listing error from the replica client, cache miss plus remote listing failure, or a context cancellation/timeout during listing.","commonSituations":"Object-storage outages, expired credentials, request timeouts on large level listings, misconfigured replica client pointing at a nonexistent prefix, or context deadline exceeded on slow networks.","solutions":["Check the wrapped error from the replica client for storage-specific causes (auth, missing prefix, throttling).","Increase context timeout for compaction operations on slow storage; verify network path to the backend.","Confirm the replica contains the expected level directories (L0/L1/L2/snapshot); a wiped or partially restored replica can break listings.","Retry; compaction monitors re-invoke CompactDB on the next schedule tick."],"exampleFix":"// before\ninfo, err := db.MaxLTXFileInfo(ctx, level)\n// after\nctx, cancel := context.WithTimeout(ctx, 5*time.Minute)\ndefer cancel()\ninfo, err := db.MaxLTXFileInfo(ctx, level)\nif err != nil {\n    return fmt.Errorf(\"fetch src level info: %w\", err)\n}","handlingStrategy":"retry","validationCode":"ctx, cancel := context.WithTimeout(ctx, 5*time.Minute)\ndefer cancel()\n// preflight listing before compaction\nitr, err := replicaClient.LTXFiles(ctx, srcLevel, 0, false)\nif err != nil {\n    return fmt.Errorf(\"cannot list src level %d: %w\", srcLevel, err)\n}\nitr.Close()","typeGuard":null,"tryCatchPattern":"if _, err := store.CompactDB(ctx, db, dstLevel); err != nil {\n    if errors.Is(err, context.DeadlineExceeded) {\n        log.Printf(\"compaction listing timed out; retrying next cycle\")\n        return nil\n    }\n    return err\n}","preventionTips":["Use long-enough context timeouts for large level listings","Verify level prefixes exist after any replica migration","Monitor object-storage throttling (429s) in logs","Keep credentials valid to avoid auth failures mid-listing"],"tags":["go","litestream","compaction","storage"],"backgroundTag":"http-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"}