{"record":{"id":"3618f4dd70ae0d65","repo":"benbjohnson/litestream","slug":"acquire-exclusive-lock-w","errorCode":null,"errorMessage":"acquire exclusive lock: %w","messagePattern":"acquire exclusive lock: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"replica.go","lineNumber":961,"sourceCode":"// (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)\n\t\tif err := dec.DecodePage(&phdr, data); err == io.EOF {\n\t\t\tbreak\n\t\t} else if err != nil {\n\t\t\treturn fmt.Errorf(\"decode page: %w\", err)\n\t\t}\n\n\t\tif phdr.Pgno == 1 && len(data) >= 28 {\n\t\t\tdata[18], data[19] = 0x01, 0x01\n\t\t\t_, _ = rand.Read(data[24:28])\n\t\t}\n\n\t\toff := int64(phdr.Pgno-1) * int64(pageSize)","sourceCodeStart":943,"sourceCodeEnd":979,"githubUrl":"https://github.com/benbjohnson/litestream/blob/4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3/replica.go#L943-L979","documentation":"applyLTXFile could not acquire the exclusive file lock on the followed database before writing pages. Another process (a SQLite reader/writer or second litestream) holds the file, so the apply is aborted to avoid partial updates.","triggerScenarios":"Thrown at replica.go:961 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Stop concurrent accessors of the followed database file","Ensure only one litestream follow process runs per database"],"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"}