{"record":{"id":"749a152f6c99410d","repo":"benbjohnson/litestream","slug":"create-temp-database-path-w","errorCode":null,"errorMessage":"create temp database path: %w","messagePattern":"create temp database path: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"replica.go","lineNumber":734,"sourceCode":"\t}\n\n\t// Create parent directory if it doesn't exist.\n\tvar dirInfo os.FileInfo\n\tif db := r.DB(); db != nil {\n\t\tdirInfo = db.dirInfo\n\t}\n\tif err := internal.MkdirAll(filepath.Dir(opt.OutputPath), dirInfo); err != nil {\n\t\treturn fmt.Errorf(\"create parent directory: %w\", err)\n\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)","sourceCodeStart":716,"sourceCodeEnd":752,"githubUrl":"https://github.com/benbjohnson/litestream/blob/4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3/replica.go#L716-L752","documentation":"Restore could not create the temporary file (<output>.tmp) that results are compacted into before the atomic rename. Permission denial in the output directory or a name collision with a leftover .tmp file.","triggerScenarios":"Thrown at replica.go:734 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check write permissions on the output directory","Remove a stale <output>.tmp left by a crashed restore"],"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-14T00:17:10.932Z"}