{"record":{"id":"022026338ea130da","repo":"JuliusBrussee/caveman","slug":"file-changed-while-opening","errorCode":null,"errorMessage":"file changed while opening","messagePattern":"file changed while opening","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/ccr/store_sqlite.go","lineNumber":285,"sourceCode":"\tif info.Mode()&os.ModeSymlink != 0 || !info.Mode().IsRegular() {\n\t\treturn fmt.Errorf(\"refusing non-regular file\")\n\t}\n\tfile, err := os.OpenFile(path, os.O_RDWR, 0)\n\tif errors.Is(err, os.ErrNotExist) && !create {\n\t\t// The sidecar vanished between Lstat and open — a concurrent process\n\t\t// checkpointed the WAL and removed it. Nothing left to secure.\n\t\treturn nil\n\t}\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer file.Close()\n\topened, err := file.Stat()\n\tif err != nil {\n\t\treturn err\n\t}\n\tif !os.SameFile(info, opened) {\n\t\treturn fmt.Errorf(\"file changed while opening\")\n\t}\n\treturn file.Chmod(0o600)\n}\n\nfunc configureStorageBudget(db *sql.DB, maxBytes int64) error {\n\tvar pageSize int64\n\tif err := db.QueryRow(`PRAGMA page_size`).Scan(&pageSize); err != nil {\n\t\treturn fmt.Errorf(\"read page size: %w\", err)\n\t}\n\tif pageSize <= 0 {\n\t\treturn errors.New(\"invalid sqlite page size\")\n\t}\n\tmaxPages := maxBytes / pageSize\n\tif maxPages < 16 {\n\t\treturn fmt.Errorf(\"budget %d is below SQLite minimum %d\", maxBytes, 16*pageSize)\n\t}\n\tvar applied int64\n\tif err := db.QueryRow(fmt.Sprintf(`PRAGMA max_page_count=%d`, maxPages)).Scan(&applied); err != nil {","sourceCodeStart":267,"sourceCodeEnd":303,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/27d5a3981a347890211bb1bf2439e5c821a63bc9/engine/ccr/store_sqlite.go#L267-L303","documentation":"Error \"file changed while opening\" thrown in JuliusBrussee/caveman.","triggerScenarios":"Thrown at engine/ccr/store_sqlite.go:285 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["The file changed while opening; retry the operation."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"27d5a3981a347890211bb1bf2439e5c821a63bc9","analyzedAt":"2026-08-15T09:26:11.751Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}