{"record":{"id":"24e89598d79b80ab","repo":"benbjohnson/litestream","slug":"new-ltx-compactor-w","errorCode":null,"errorMessage":"new ltx compactor: %w","messagePattern":"new ltx compactor: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"replica.go","lineNumber":743,"sourceCode":"\t}\n\n\t// Output to temp file & atomically rename.\n\ttmpOutputPath := opt.OutputPath + \".tmp\"\n\tr.Logger().Debug(\"compacting into database\", \"path\", tmpOutputPath, \"n\", len(rdrs))\n\tdefer func() { _ = os.Remove(tmpOutputPath) }()\n\n\tf, err := os.Create(tmpOutputPath)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"create temp database path: %w\", err)\n\t}\n\tdefer func() { _ = f.Close() }()\n\n\tpr, pw := io.Pipe()\n\n\tgo func() {\n\t\tc, err := ltx.NewCompactor(pw, rdrs)\n\t\tif err != nil {\n\t\t\tpw.CloseWithError(fmt.Errorf(\"new ltx compactor: %w\", err))\n\t\t\treturn\n\t\t}\n\t\tc.HeaderFlags = ltx.HeaderFlagNoChecksum\n\t\t_ = pw.CloseWithError(c.Compact(ctx))\n\t}()\n\n\tdec := ltx.NewDecoder(pr)\n\tif err := dec.DecodeDatabaseTo(f); err != nil {\n\t\treturn fmt.Errorf(\"decode database: %w\", err)\n\t}\n\n\tif err := f.Sync(); err != nil {\n\t\treturn err\n\t} else if err := f.Close(); err != nil {\n\t\treturn err\n\t}\n\n\t// Copy file to final location.","sourceCodeStart":725,"sourceCodeEnd":761,"githubUrl":"https://github.com/benbjohnson/litestream/blob/4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3/replica.go#L725-L761","documentation":"ltx.NewCompactor failed to initialize over the plan's readers — typically an LTX header mismatch (incompatible versions, page sizes, or non-contiguous TXID ranges) in the selected backup files. The error surfaces through the compaction pipe.","triggerScenarios":"Thrown at replica.go:743 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the LTX chain is contiguous (litestream ltx per level)","Re-take a snapshot and rebuild history if the chain is inconsistent"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}