{"record":{"id":"8ed007b9dac451f2","repo":"tursodatabase/turso","slug":"first-query-runs-require-one-query-per-connection-use-warm","errorCode":null,"errorMessage":"first-query runs require one query per connection; use warm for repeated transactions","messagePattern":"first-query runs require one query per connection; use warm for repeated transactions","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"perf/memory/src/fts.rs","lineNumber":286,"sourceCode":"impl 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\"))?;\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,","sourceCodeStart":268,"sourceCodeEnd":304,"githubUrl":"https://github.com/tursodatabase/turso/blob/492c4a71cd7c2649e7df83da1471b74f4b1c7aa9/perf/memory/src/fts.rs#L268-L304","documentation":"When state is QueryState::First (first-query measurement), validate() demands exactly one batch with one query per connection, because first-query timing/memory is only meaningful for a single initial query. Any other shape is rejected with guidance to use the warm state for repeated-transaction runs.","triggerScenarios":"Running with state = First while execution.batches() != 1 or queries_per_batch() != 1, e.g. --state first --queries-per-transaction 5 or multiple batches.","commonSituations":"Combining first-query mode with a workload tuned for warm runs; reusing a warm-run config and only flipping the state flag; scripting that appends extra queries while keeping First state.","solutions":["Use one batch with exactly one query per connection when state is First","Switch state to QueryState::Warm if you want repeated queries/transactions","Split the run: do first-query measurement separately from the warm repeated-transaction measurement"],"exampleFix":"// before\nFtsConfig { state: QueryState::First, execution: Execution { queries_per_transaction: 5, .. } }\n// after\nFtsConfig { state: QueryState::Warm, execution: Execution { queries_per_transaction: 5, .. } }","handlingStrategy":"validation","validationCode":"if state == QueryState::First && !(execution.batches() == 1 && execution.queries_per_batch() == 1) {\n    return Err(anyhow!(\"First state requires exactly one query per connection\"));\n}","typeGuard":null,"tryCatchPattern":"if let Err(e) = config.validate() {\n    if e.to_string().contains(\"first-query runs require one query\") {\n        // switch state to Warm or reduce workload to a single query\n    }\n}","preventionTips":["Keep separate configs for first-query and warm measurements","Never flip the state flag on a warm-run config without adjusting the workload","Read validate()'s message — it names the compatible state directly"],"tags":["configuration","validation","mutually-exclusive","benchmark"],"backgroundTag":"conflicting-config-options","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"}