{"record":{"id":"61924dfeacdd2ebb","repo":"benbjohnson/litestream","slug":"write-txid-file-w","errorCode":null,"errorMessage":"write txid file: %w","messagePattern":"write txid file: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"replica.go","lineNumber":852,"sourceCode":"\tfor {\n\t\tselect {\n\t\tcase <-ctx.Done():\n\t\t\tr.Logger().Info(\"follow mode stopped\")\n\t\t\treturn nil\n\t\tcase <-ticker.C:\n\t\t\tnewTXID, err := r.applyNewLTXFiles(ctx, f, lastTXID, pageSize)\n\t\t\tif err != nil {\n\t\t\t\tif ctx.Err() != nil {\n\t\t\t\t\tr.Logger().Info(\"follow mode stopped\")\n\t\t\t\t\treturn nil\n\t\t\t\t}\n\t\t\t\tconsecutiveErrors++\n\t\t\t\tr.Logger().Error(\"follow: error applying updates\", \"err\", err, \"consecutive_errors\", consecutiveErrors)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif newTXID > lastTXID {\n\t\t\t\tif err := WriteTXIDFile(outputPath, newTXID); err != nil {\n\t\t\t\t\treturn fmt.Errorf(\"write txid file: %w\", err)\n\t\t\t\t}\n\t\t\t\tr.Logger().Info(\"follow: applied updates\", \"from_txid\", lastTXID, \"to_txid\", newTXID)\n\t\t\t\tlastTXID = newTXID\n\t\t\t\tconsecutiveErrors = 0\n\t\t\t}\n\t\t}\n\t}\n}\n\n// applyNewLTXFiles polls for new LTX files and applies them to the database.\n// It starts from level 0 and falls back to higher levels if there are gaps\n// (e.g., level 0 files were compacted away).\nfunc (r *Replica) applyNewLTXFiles(ctx context.Context, f *os.File, afterTXID ltx.TXID, pageSize uint32) (ltx.TXID, error) {\n\tcurrentTXID := afterTXID\n\n\t// Poll level 0 for the most recent incremental files.\n\titr, err := r.Client.LTXFiles(ctx, 0, currentTXID+1, false)\n\tif err != nil {","sourceCodeStart":834,"sourceCodeEnd":870,"githubUrl":"https://github.com/benbjohnson/litestream/blob/4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3/replica.go#L834-L870","documentation":"In the follow loop, WriteTXIDFile failed after successfully applying new LTX files — the sidecar recording the new high-water TXID could not be written. Progress is applied to the DB but not durable for crash recovery; causes are disk/permission errors.","triggerScenarios":"Thrown at replica.go:852 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check disk space and permissions on the sidecar path","Restart litestream; crash recovery will validate the last successfully written TXID"],"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-14T00:17:10.932Z"}