apache/cassandra · error · IllegalArgumentException

Log interval must be greater than zero

Error message

Log interval must be greater than zero

What it means

cassandra-stress parses the -log interval option (e.g. '10ms', '5s' or a bare seconds value) into milliseconds and refuses non-positive values. IllegalArgumentException is thrown from the SettingsLog constructor because a zero or negative interval would disable or invert periodic logging of progress.

Solutions

  1. Pass a positive interval, e.g. -log interval=10s
  2. Check the unit suffix: bare values are seconds, 'ms' is milliseconds; ensure the number is >0
  3. If you want no periodic logging, omit the interval option entirely instead of setting it to 0

Example fix

// before
cassandra-stress write -log interval=0s
// after
cassandra-stress write -log interval=10s
Defensive patterns

Strategy: validation

Validate before calling

int millis = parseIntervalMillis(args.value("interval"));
if (args.containsKey("interval") && millis <= 0)
    throw new IllegalArgumentException("interval must be > 0, e.g. 10s");

Try / catch

try { SettingsLog.get(clArgs); } catch (IllegalArgumentException e) { if (e.getMessage().contains("Log interval")) { /* correct -log interval and retry */ } else throw e; }

Prevention

When it happens

Trigger: Running cassandra-stress with '-log interval=0', 'interval=-5s', or any interval that parses to <=0 milliseconds (e.g. 'interval=0s').

Common situations: Copy-pasted stress configs where the interval was blanked to 0 to 'disable' logging; scripted invocations computing interval from a variable that evaluated to 0.

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10). Data as JSON: /api/errors/72630f1fa4fbc3b9. Report an issue: GitHub.

Appendix: source

Thrown at tools/stress/src/org/apache/cassandra/stress/settings/SettingsLog.java:73

        noSettings = options.noSettings.setByUser();

        if (options.outputFile.setByUser())
            file = new File(options.outputFile.value());
        else
            file = null;
        if (options.hdrOutputFile.setByUser())
            hdrFile = new File(options.hdrOutputFile.value());
        else
            hdrFile = null;
        String interval = options.interval.value();
        if (interval.endsWith("ms"))
            intervalMillis = Integer.parseInt(interval.substring(0, interval.length() - 2));
        else if (interval.endsWith("s"))
            intervalMillis = 1000 * Integer.parseInt(interval.substring(0, interval.length() - 1));
        else
            intervalMillis = 1000 * Integer.parseInt(interval);
        if (intervalMillis <= 0)
            throw new IllegalArgumentException("Log interval must be greater than zero");
        level = Level.valueOf(toUpperCaseLocalized(options.level.value()));
    }

    public MultiResultLogger getOutput() throws FileNotFoundException
    {
        // Always print to stdout regardless of whether we're graphing or not
        MultiResultLogger stream = new MultiResultLogger(new PrintStream(System.out));

        if (file != null)
            stream.addStream(new PrintStream(file));

        return stream;
    }

    // Option Declarations

    public static final class Options extends GroupedOptions
    {

View on GitHub (pinned to 88fd0f6a0e)