{"record":{"id":"6620fb37c4d239f6","repo":"JuliusBrussee/caveman","slug":"invalid-sqlite-page-size","errorCode":null,"errorMessage":"invalid sqlite page size","messagePattern":"invalid sqlite page size","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/ccr/store_sqlite.go","lineNumber":296,"sourceCode":"\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\n\t}\n\tif _, err := db.Exec(fmt.Sprintf(`PRAGMA wal_autocheckpoint=%d`, autoCheckpoint)); err != nil {\n\t\treturn err","sourceCodeStart":278,"sourceCodeEnd":314,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/766dce6b1394ebb56a3090748d5a0240a5aefb36/engine/ccr/store_sqlite.go#L278-L314","documentation":"configureStorageBudget read a non-positive page_size PRAGMA from the SQLite database while setting up the max-/pages budget mapping. A healthy SQLite file always reports a positive page size, so this indicates a corrupt or non-SQLite file.","triggerScenarios":"Thrown at engine/ccr/store_sqlite.go:296 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Point the store at a valid SQLite database file or a fresh path so one is created","Inspect the file with 'PRAGMA integrity_check' and recreate it if corrupt"],"exampleFix":null,"handlingStrategy":"validation","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-14T00:17:10.932Z"}