{"record":{"id":"85cfd56a6e2e369e","repo":"benbjohnson/litestream","slug":"open-ltx-file-w","errorCode":null,"errorMessage":"open ltx file: %w","messagePattern":"open ltx file: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"replica.go","lineNumber":949,"sourceCode":"\t\t}\n\t\tcurrentTXID = bridgedTXID\n\t}\n\n\treturn currentTXID, nil\n}\n\n// applyLTXFile applies a single LTX file's pages to the database file.\n// This follows the same pattern as Hydrator.ApplyLTX (vfs.go:712-747).\n//\n// To prevent concurrent SQLite readers from seeing partial updates, we acquire\n// an exclusive file lock before writing. We also rewrite the SQLite header\n// (bytes 18-19) to indicate DELETE journal mode instead of WAL mode, and\n// randomize the schema change counter (bytes 24-27) to invalidate cached\n// schemas in other connections.\nfunc (r *Replica) applyLTXFile(ctx context.Context, f *os.File, info *ltx.FileInfo, pageSize uint32) error {\n\trc, err := r.Client.OpenLTXFile(ctx, info.Level, info.MinTXID, info.MaxTXID, 0, 0)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"open ltx file: %w\", err)\n\t}\n\tdefer rc.Close()\n\n\tdec := ltx.NewDecoder(rc)\n\tif err := dec.DecodeHeader(); err != nil {\n\t\treturn fmt.Errorf(\"decode header: %w\", err)\n\t}\n\n\thdr := dec.Header()\n\n\tif err := internal.LockFileExclusive(f); err != nil {\n\t\treturn fmt.Errorf(\"acquire exclusive lock: %w\", err)\n\t}\n\tdefer internal.UnlockFile(f)\n\n\tfor {\n\t\tvar phdr ltx.PageHeader\n\t\tdata := make([]byte, pageSize)","sourceCodeStart":931,"sourceCodeEnd":967,"githubUrl":"https://github.com/benbjohnson/litestream/blob/4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3/replica.go#L931-L967","documentation":"applyLTXFile's OpenLTXFile call on the replica failed for a reason other than not-exists. The backend could not serve the LTX file identified by level/min/max TXID — connectivity, credentials, or corrupted object metadata.","triggerScenarios":"Thrown at replica.go:949 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check backend connectivity and read permissions","Verify the LTX file exists (litestream ltx <level>)","Follow mode retries applying the same file on the next poll"],"exampleFix":null,"handlingStrategy":"retry","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"}