apache/cassandra · error · IllegalArgumentException

Threshold value for gc_warn*_threshold must be less than Int

Error message

Threshold value for gc_warn*_threshold must be less than Integer.MAX_VALUE

What it means

Cassandra throws this IllegalArgumentException from validateGCParams when the GC warn threshold exceeds Integer.MAX_VALUE milliseconds. Like the log threshold, the warn threshold is stored as an int millisecond bound and cannot exceed the int range.

Source

Thrown at src/java/org/apache/cassandra/config/DatabaseDescriptor.java:5020

    }

    public static void setGCLogThreshold(int threshold)
    {
        validateGCParams(threshold, getGCWarnThreshold());
        conf.gc_log_threshold = new DurationSpec.IntMillisecondsBound(threshold);
    }

    public static void validateGCParams(long logThreshold, long warnThreshold)
    {
        if (logThreshold <= 0)
            throw new IllegalArgumentException("Threshold value for gc_log*_threshold must be greater than 0");
        if (logThreshold > Integer.MAX_VALUE)
            throw new IllegalArgumentException("Threshold value for gc_log*_threshold must be less than Integer.MAX_VALUE");

        if (warnThreshold <= 0)
            throw new IllegalArgumentException("Threshold value for gc_warn*_threshold must be greater than 0");
        if (warnThreshold > Integer.MAX_VALUE)
            throw new IllegalArgumentException("Threshold value for gc_warn*_threshold must be less than Integer.MAX_VALUE");

        if (warnThreshold != 0 && logThreshold > warnThreshold)
            throw new IllegalArgumentException("Threshold value for gc_log*_threshold (" + logThreshold + ") must be less than gc_warn*_threshold which is currently "
                    + warnThreshold);
    }

    public static EncryptionContext getEncryptionContext()
    {
        return encryptionContext;

    }

    public static long getGCWarnThreshold()
    {
        return conf.gc_warn_threshold.toMilliseconds();
    }

    public static void setGCWarnThreshold(long threshold)

View on GitHub (pinned to 88fd0f6a0e)

Solutions

  1. Set gc_warn_threshold below Integer.MAX_VALUE ms
  2. Use a large but sane value like 600000ms (10 minutes) to suppress most warnings
  3. Validate the parsed value before calling validateGCParams

Example fix

// before
validateGCParams(200L, 3_000_000_000L);
// after
validateGCParams(200L, 600_000L);
Defensive patterns

Strategy: validation

Validate before calling

if (warnThreshold > Integer.MAX_VALUE)
    warnThreshold = Integer.MAX_VALUE; // or reject

Try / catch

try {
    DatabaseDescriptor.validateGCParams(logThreshold, warnThreshold);
} catch (IllegalArgumentException e) {
    logger.error("gc_warn_threshold out of int range", e);
}

Prevention

When it happens

Trigger: Calling validateGCParams with warnThreshold > 2147483647, from cassandra.yaml gc_warn_threshold misconfigured with wrong units or an unclamped long.

Common situations: Unit confusion (e.g. entering nanoseconds), or attempts to 'effectively disable' warnings with an astronomically large value.

Understand the failure class

Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.

Related errors


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