{"record":{"id":"8846e9d9004a8b6d","repo":"tursodatabase/turso","slug":"cache-pages-must-be-between-200-and-i32-max","errorCode":null,"errorMessage":"cache pages must be between 200 and i32::MAX","messagePattern":"cache pages must be between 200 and i32::MAX","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"perf/memory/src/fts.rs","lineNumber":271,"sourceCode":"                let batch = worker??;\n                result.queries += batch.queries;\n                result.rows += batch.rows;\n                result.id_sum += batch.id_sum;\n            }\n            Ok(result)\n        }\n        .await;\n        if result.is_err() {\n            workers.shutdown().await;\n        }\n        result\n    }\n}\n\nimpl FtsConfig {\n    pub fn validate(&self) -> Result<()> {\n        ensure!(self.documents > 0, \"documents must be positive\");\n        ensure!(\n            self.corpus\n                .cache_pages\n                .is_none_or(|pages| (200..=i32::MAX as usize).contains(&pages)),\n            \"cache pages must be between 200 and i32::MAX\"\n        );\n        ensure!(self.connections > 0, \"connections must be positive\");\n        ensure!(\n            self.execution.batches() > 0,\n            \"queries or transactions must be positive\"\n        );\n        ensure!(\n            self.execution.queries_per_batch() > 0,\n            \"queries per transaction must be positive\"\n        );\n        ensure!(\n            !matches!(self.state, QueryState::First)\n                || (self.execution.batches() == 1 && self.execution.queries_per_batch() == 1),\n            \"first-query runs require one query per connection; use warm for repeated transactions\"","sourceCodeStart":253,"sourceCodeEnd":289,"githubUrl":"https://github.com/tursodatabase/turso/blob/492c4a71cd7c2649e7df83da1471b74f4b1c7aa9/perf/memory/src/fts.rs#L253-L289","documentation":"FtsConfig::validate() requires cache_pages, when provided, to be within 200..=i32::MAX. Very small page caches make the benchmark meaningless or break assumptions, and the value is stored as an i32 (SQLite cache_size), so values above i32::MAX cannot be represented. None means 'use default' and is allowed.","triggerScenarios":"Setting corpus.cache_pages to Some(n) with n < 200 or n > i32::MAX (e.g. --cache-pages 100 or --cache-pages 99999999999999).","commonSituations":"Trying to simulate a tiny cache with a sub-200 value; passing a byte-sized or 64-bit cache value that overflows i32; unit confusion (pages vs bytes).","solutions":["Set cache_pages to a value between 200 and 2147483647","Omit cache_pages (leave it None) to use the default cache size","If you intended bytes, convert to page count first (bytes / page_size) and clamp into range"],"exampleFix":"// before\nCorpusConfig { cache_pages: Some(50), .. }\n// after\nCorpusConfig { cache_pages: Some(2000), .. }","handlingStrategy":"validation","validationCode":"if let Some(pages) = cache_pages {\n    if !(200..=i32::MAX as usize).contains(&pages) {\n        return Err(anyhow!(\"cache pages must be within 200..=i32::MAX\"));\n    }\n}","typeGuard":null,"tryCatchPattern":"if let Err(e) = config.validate() {\n    if e.to_string().contains(\"cache pages\") {\n        // clamp or unset cache_pages and rebuild config\n    }\n}","preventionTips":["Remember the value is pages, not bytes — convert before passing","Clamp user input: cache_pages.map(|p| p.clamp(200, i32::MAX as usize))","Prefer leaving cache_pages as None unless tuning deliberately"],"tags":["configuration","validation","cache","range"],"backgroundTag":"value-out-of-range","analyzedSha":"492c4a71cd7c2649e7df83da1471b74f4b1c7aa9","analyzedAt":"2026-09-13T18:13:59.796Z","contentChangedAt":"2026-09-13T18:13:59.796Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}