{"record":{"id":"9bf921d80ad5f3e2","repo":"JuliusBrussee/caveman","slug":"read-page-size-w","errorCode":null,"errorMessage":"read page size: %w","messagePattern":"read page size: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/ccr/store_sqlite.go","lineNumber":293,"sourceCode":"\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 {\n\t\treturn err\n\t}\n\tif applied < maxPages {\n\t\tmaxPages = applied\n\t}\n\tautoCheckpoint := maxPages / 16\n\tif autoCheckpoint < 1 {\n\t\tautoCheckpoint = 1","sourceCodeStart":275,"sourceCodeEnd":311,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/766dce6b1394ebb56a3090748d5a0240a5aefb36/engine/ccr/store_sqlite.go#L275-L311","documentation":"Wraps the PRAGMA page_size query failure in configureStorageBudget. The page size is needed to convert the byte budget into a max-page count; if it cannot be read (locked or broken database), budget enforcement cannot be set up and opening fails.","triggerScenarios":"Thrown at engine/ccr/store_sqlite.go:293 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the wrapped error for lock or corruption causes","Ensure no other process holds the database while it is being opened","Recreate the database if it is corrupt"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"766dce6b1394ebb56a3090748d5a0240a5aefb36","analyzedAt":"2026-08-18T03:14:35.516Z","contentChangedAt":"2026-08-18T03:14:35.516Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}