{"record":{"id":"f92a5375e4de9b06","repo":"tursodatabase/turso","slug":"connections-must-be-positive","errorCode":null,"errorMessage":"connections must be positive","messagePattern":"connections must be positive","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"perf/memory/src/fts.rs","lineNumber":277,"sourceCode":"        }\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\"\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\"))?;","sourceCodeStart":259,"sourceCodeEnd":295,"githubUrl":"https://github.com/tursodatabase/turso/blob/492c4a71cd7c2649e7df83da1471b74f4b1c7aa9/perf/memory/src/fts.rs#L259-L295","documentation":"FtsConfig::validate() rejects configurations where connections is zero. The benchmark opens one session per connection and queries across all of them; with zero connections there is nothing to measure, so validation fails before setup.","triggerScenarios":"Building FtsConfig with connections == 0, e.g. --connections 0 or a default derived from an empty/zero input.","commonSituations":"Command-line typo; concurrency value loaded from an unset env var or empty config file; programmatic use where the caller passes a computed parallelism of 0.","solutions":["Pass a positive connection count, e.g. --connections 4","Clamp or default the computed value: connections.max(1)","Validate user input before constructing FtsConfig"],"exampleFix":"// before\nFtsConfig { connections: 0, .. }\n// after\nFtsConfig { connections: 4, .. }","handlingStrategy":"validation","validationCode":"if connections == 0 { return Err(anyhow!(\"connections must be > 0\")); }","typeGuard":null,"tryCatchPattern":"if let Err(e) = config.validate() {\n    if e.to_string().contains(\"connections must be positive\") {\n        // rebuild with connections.max(1)\n    }\n}","preventionTips":["Default concurrency to at least 1 when derived from environment","Validate numeric CLI args for positivity at parse time","Run validate() before opening any connections"],"tags":["configuration","validation","benchmark","fts"],"backgroundTag":"invalid-argument-value","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"}