tursodatabase/turso · error

seconds must be finite and positive

Error message

seconds must be finite and positive

What it means

The throughput duration must be a finite, strictly positive number of seconds. ensure! at perf/fts/src/main.rs:102 validates the value after applying the 5.0 default, rejecting NaN, infinity, zero, and negatives, because a non-positive or non-finite duration makes the timing loop meaningless or infinite.

Solutions

  1. Pass a positive finite --seconds value, e.g. --seconds 5
  2. Omit --seconds to use the built-in 5.0 second default
  3. Fix the upstream script/variable that computes the duration

Example fix

// before
fts-bench --benchmark throughput --state warm --seconds 0
// after
fts-bench --benchmark throughput --state warm --seconds 5
Defensive patterns

Strategy: validation

Validate before calling

let s: f64 = seconds.parse()?; if !s.is_finite() || s <= 0.0 { panic!("--seconds must be finite and > 0"); }

Type guard

fn valid_seconds(v: f64) -> bool { v.is_finite() && v > 0.0 }

Prevention

When it happens

Trigger: Passing --seconds 0, --seconds -5, --seconds nan, --seconds inf, or any value that parses to a non-finite/non-positive f64 while in throughput mode.

Common situations: Shell variables interpolating to empty/zero; mis-typed units like --seconds 0.0; programmatic CLI construction with uninitialized or divided-by-zero floats.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


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

Appendix: source

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

                "need at least one query per connection"
            );
            ensure!(
                !matches!(args.state, QueryState::First) || queries == args.connections,
                "first-query latency requires one query per connection"
            );
            (queries, 0.0)
        }
        Benchmark::Throughput => {
            ensure!(
                args.queries.is_none(),
                "--queries requires --benchmark search"
            );
            ensure!(
                matches!(args.state, QueryState::Warm),
                "throughput requires --state warm"
            );
            let seconds = args.seconds.unwrap_or(5.0);
            ensure!(
                seconds.is_finite() && seconds > 0.0,
                "seconds must be finite and positive"
            );
            (0, seconds)
        }
    };
    #[cfg(all(feature = "flamegraph", any(target_os = "linux", target_os = "macos")))]
    let profiled = args.flamegraph.is_some();
    #[cfg(not(all(feature = "flamegraph", any(target_os = "linux", target_os = "macos"))))]
    let profiled = false;
    #[cfg(all(feature = "flamegraph", any(target_os = "linux", target_os = "macos")))]
    if let Some(directory) = &args.flamegraph {
        std::fs::create_dir(directory)?;
    }
    let mut output = stdout().lock();
    writeln!(
        output,
        "benchmark,engine,mode,state,documents,connections,queries,run,query,seconds,rows,id_sum,debug_assertions,requested_queries,min_seconds,p50_ms,p95_ms,p99_ms,profiled"

View on GitHub (pinned to 8d4a589f8d)