apache/cassandra · error · IllegalArgumentException

compaction_throughput: is too large; it should be less than

Error message

compaction_throughput: is too large; it should be less than 2147483647 in MiB/s

What it means

setCompactionThroughputBytesPerSec converts a bytes/sec value to MiB/s and rejects values that equal or exceed Integer.MAX_VALUE MiB/s. The stored config type is bounded by the int-representable MiB/s range, so absurdly large byte rates are refused with IllegalArgumentException.

Source

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

    {
        return conf.compaction_throughput.toMebibytesPerSecondAsInt();
    }

    public static double getCompactionThroughputBytesPerSec()
    {
        return conf.compaction_throughput.toBytesPerSecond();
    }

    public static double getCompactionThroughputMebibytesPerSec()
    {
        return conf.compaction_throughput.toMebibytesPerSecond();
    }

    @VisibleForTesting // only for testing!
    public static void setCompactionThroughputBytesPerSec(int value)
    {
        if (BYTES_PER_SECOND.toMebibytesPerSecond(value) >= Integer.MAX_VALUE)
            throw new IllegalArgumentException("compaction_throughput: " + value +
                                               " is too large; it should be less than " +
                                               Integer.MAX_VALUE + " in MiB/s");

        conf.compaction_throughput = new DataRateSpec.LongBytesPerSecondBound(value);
    }

    public static void setCompactionThroughputMebibytesPerSec(int value)
    {
        if (value == Integer.MAX_VALUE)
            throw new IllegalArgumentException("compaction_throughput: " + value +
                                               " is too large; it should be less than " +
                                               Integer.MAX_VALUE + " in MiB/s");

        conf.compaction_throughput = new DataRateSpec.LongBytesPerSecondBound(value, MEBIBYTES_PER_SECOND);
    }

    public static int getConcurrentValidations()
    {

View on GitHub (pinned to 88fd0f6a0e)

Solutions

  1. Pass a realistic byte-per-second value well below Integer.MAX_VALUE MiB/s.
  2. Use setCompactionThroughputMebibytesPerSec for large values expressed in MiB/s.
  3. Validate the converted MiB/s value before calling.

Example fix

// before
databaseDescriptor.setCompactionThroughputBytesPerSec(Long.MAX_VALUE);
// after
databaseDescriptor.setCompactionThroughputMebibytesPerSec(64); // 64 MiB/s
Defensive patterns

Strategy: validation

Validate before calling

long mibPerSec = DataRateSpec.DataRateUnit.BYTES_PER_SECOND.toMebibytesPerSecond(bytesPerSec);
if (mibPerSec >= 0 && mibPerSec < Integer.MAX_VALUE) DatabaseDescriptor.setCompactionThroughputBytesPerSec((int) Math.min(bytesPerSec, Integer.MAX_VALUE));

Type guard

boolean isValidCompactionBytesPerSec(long v) { return v >= 0 && DataRateSpec.DataRateUnit.BYTES_PER_SECOND.toMebibytesPerSecond(v) < Integer.MAX_VALUE; }

Try / catch

try { DatabaseDescriptor.setCompactionThroughputBytesPerSec(v); } catch (IllegalArgumentException e) { log.error("compaction_throughput too large: {}", v, e); }

Prevention

When it happens

Trigger: Calling DatabaseDescriptor.setCompactionThroughputBytesPerSec(value) where BYTES_PER_SECOND.toMebibytesPerSecond(value) >= 2147483647, i.e. values above roughly 2.25e18 bytes/sec (also Integer.MIN_VALUE overflows into this check).

Common situations: Passing Long or unvalidated user input into the int-based setter; unit confusion (bytes vs MiB); scripted config changes with sentinel values like Long.MAX_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/6dd0c9002a7cea59. Report an issue: GitHub.