tursodatabase/turso · error

connections must be positive

Error message

connections must be positive

What it means

Command-line argument validation in main: the --connections option was given a value of zero, which makes no sense for a benchmark that runs queries across N concurrent connections. This is a clap-adjacent ensure! guard rejecting a non-positive --connections value; pass 1 or more.

Solutions

  1. Re-run with `--connections` set to a positive integer (e.g. `--connections 4`).
  2. Fix the source of the connection count (env var/config) to be >= 1.
  3. Add a clap value_parser range so invalid values are rejected at parse time with a usage message.

Example fix

// before
perf-fts --connections 0
// after
perf-fts --connections 4
Defensive patterns

Strategy: validation

Validate before calling

if connections <= 0 { eprintln!("--connections must be a positive integer"); std::process::exit(2); }

Prevention

When it happens

Trigger: Invoking the perf/fts binary with `--connections 0` or a negative value.

Common situations: A shell variable holding the connection count defaulting to 0, or a config/script bug computing thread counts.

Understand the failure class

Background: "Unknown argument", "Invalid value", and "must be one of": invalid CLI argument errors explained — this error's family across 35 libraries.

Related errors


AI-assisted analysis of tursodatabase/turso@8d4a589f8d (2026-09-20). Data as JSON: /api/errors/eb7b9f521d287d50. Report an issue: GitHub.

Appendix: source

Thrown at perf/fts/src/main.rs:53

    targets: Vec<Target>,
    #[arg(long, default_value_t = 1)]
    connections: usize,
    #[arg(
        long,
        value_enum,
        value_delimiter = ',',
        default_value = "rare,common,and,or,phrase,ranked"
    )]
    cases: Vec<QueryCase>,
    #[cfg(all(feature = "flamegraph", any(target_os = "linux", target_os = "macos")))]
    #[arg(long)]
    flamegraph: Option<std::path::PathBuf>,
}

fn main() -> Result<()> {
    let args = Args::parse();
    ensure!(args.runs > 0, "runs must be positive");
    ensure!(args.connections > 0, "connections must be positive");
    eprintln!("bundled SQLite version: {}", rusqlite::version());
    let runtime = match args.benchmark {
        Benchmark::Search => tokio::runtime::Builder::new_current_thread()
            .enable_all()
            .build()?,
        Benchmark::Throughput => tokio::runtime::Builder::new_multi_thread()
            .worker_threads(args.connections)
            .max_blocking_threads(args.connections)
            .enable_all()
            .build()?,
    };
    runtime.block_on(run(args))
}

async fn run(mut args: Args) -> Result<()> {
    let (query_limit, min_seconds) = match args.benchmark {
        Benchmark::Search => {
            ensure!(

View on GitHub (pinned to 8d4a589f8d)