{"record":{"id":"5328505f906acd3e","repo":"tursodatabase/turso","slug":"total-query-count-overflows-usize","errorCode":null,"errorMessage":"total query count overflows usize","messagePattern":"total query count overflows usize","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"perf/memory/src/fts.rs","lineNumber":295,"sourceCode":"        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\"\n        );\n        self.execution\n            .batches()\n            .checked_mul(self.execution.queries_per_batch())\n            .and_then(|n| n.checked_mul(self.connections))\n            .ok_or_else(|| anyhow::anyhow!(\"total query count overflows usize\"))?;\n        Ok(())\n    }\n}\n\nimpl Execution {\n    pub fn batches(self) -> usize {\n        match self {\n            Self::Queries(queries) => queries,\n            Self::Transactions { per_connection, .. } => per_connection,\n        }\n    }\n\n    fn queries_per_batch(self) -> usize {\n        match self {\n            Self::Queries(_) => 1,\n            Self::Transactions {\n                queries_per_transaction,\n                ..","sourceCodeStart":277,"sourceCodeEnd":313,"githubUrl":"https://github.com/tursodatabase/turso/blob/492c4a71cd7c2649e7df83da1471b74f4b1c7aa9/perf/memory/src/fts.rs#L277-L313","documentation":"validate() computes total queries as batches * queries_per_batch * connections using checked arithmetic. If the product overflows usize, the total workload cannot be represented, so validation fails with this error instead of silently wrapping.","triggerScenarios":"Setting extremely large values for queries/queries-per-transaction/connections whose product exceeds usize::MAX (only plausible on 32-bit targets or with absurd 64-bit values).","commonSituations":"Passing an unvalidated 64-bit number from a config file on a 32-bit build; a runaway multiplier in generated configs; unit mistake (passing total queries as queries-per-transaction).","solutions":["Reduce batches, queries per transaction, or connections to a realistic product","Compute the intended total in u128 and pick smaller factors before building the config","If on a 32-bit target, run the benchmark on a 64-bit platform or lower the workload"],"exampleFix":"// before\nExecution { batches: usize::MAX, queries_per_transaction: usize::MAX, .. }\n// after\nExecution { batches: 100, queries_per_transaction: 10, .. }","handlingStrategy":"validation","validationCode":"let total = batches as u128 * queries_per_batch as u128 * connections as u128;\nif total > usize::MAX as u128 { return Err(anyhow!(\"total query count too large\")); }","typeGuard":null,"tryCatchPattern":"if let Err(e) = config.validate() {\n    if e.to_string().contains(\"overflows usize\") {\n        // scale the workload down and rebuild the config\n    }\n}","preventionTips":["Sanity-check workload totals in u128 before building the config","Cap user-supplied workload multipliers to realistic bounds","Be extra careful with 32-bit builds where usize is small"],"tags":["configuration","validation","overflow","arithmetic"],"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-14T00:17:10.932Z"}