{"record":{"id":"6dd0c9002a7cea59","repo":"apache/cassandra","slug":"compaction-throughput-is-too-large-it-should-be","errorCode":null,"errorMessage":"compaction_throughput: is too large; it should be less than 2147483647 in MiB/s","messagePattern":"compaction_throughput: is too large; it should be less than 2147483647 in MiB/s","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/config/DatabaseDescriptor.java","lineNumber":3045,"sourceCode":"    {\n        return conf.compaction_throughput.toMebibytesPerSecondAsInt();\n    }\n\n    public static double getCompactionThroughputBytesPerSec()\n    {\n        return conf.compaction_throughput.toBytesPerSecond();\n    }\n\n    public static double getCompactionThroughputMebibytesPerSec()\n    {\n        return conf.compaction_throughput.toMebibytesPerSecond();\n    }\n\n    @VisibleForTesting // only for testing!\n    public static void setCompactionThroughputBytesPerSec(int value)\n    {\n        if (BYTES_PER_SECOND.toMebibytesPerSecond(value) >= Integer.MAX_VALUE)\n            throw new IllegalArgumentException(\"compaction_throughput: \" + value +\n                                               \" is too large; it should be less than \" +\n                                               Integer.MAX_VALUE + \" in MiB/s\");\n\n        conf.compaction_throughput = new DataRateSpec.LongBytesPerSecondBound(value);\n    }\n\n    public static void setCompactionThroughputMebibytesPerSec(int value)\n    {\n        if (value == Integer.MAX_VALUE)\n            throw new IllegalArgumentException(\"compaction_throughput: \" + value +\n                                               \" is too large; it should be less than \" +\n                                               Integer.MAX_VALUE + \" in MiB/s\");\n\n        conf.compaction_throughput = new DataRateSpec.LongBytesPerSecondBound(value, MEBIBYTES_PER_SECOND);\n    }\n\n    public static int getConcurrentValidations()\n    {","sourceCodeStart":3027,"sourceCodeEnd":3063,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/config/DatabaseDescriptor.java#L3027-L3063","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Pass a realistic byte-per-second value well below Integer.MAX_VALUE MiB/s.","Use setCompactionThroughputMebibytesPerSec for large values expressed in MiB/s.","Validate the converted MiB/s value before calling."],"exampleFix":"// before\ndatabaseDescriptor.setCompactionThroughputBytesPerSec(Long.MAX_VALUE);\n// after\ndatabaseDescriptor.setCompactionThroughputMebibytesPerSec(64); // 64 MiB/s","handlingStrategy":"validation","validationCode":"long mibPerSec = DataRateSpec.DataRateUnit.BYTES_PER_SECOND.toMebibytesPerSecond(bytesPerSec);\nif (mibPerSec >= 0 && mibPerSec < Integer.MAX_VALUE) DatabaseDescriptor.setCompactionThroughputBytesPerSec((int) Math.min(bytesPerSec, Integer.MAX_VALUE));","typeGuard":"boolean isValidCompactionBytesPerSec(long v) { return v >= 0 && DataRateSpec.DataRateUnit.BYTES_PER_SECOND.toMebibytesPerSecond(v) < Integer.MAX_VALUE; }","tryCatchPattern":"try { DatabaseDescriptor.setCompactionThroughputBytesPerSec(v); } catch (IllegalArgumentException e) { log.error(\"compaction_throughput too large: {}\", v, e); }","preventionTips":["Prefer the MebibytesPerSec setter for large rates","Never pass Long.MAX_VALUE or min-int sentinels into int-based setters","Convert units explicitly before calling byte-based setters"],"tags":["configuration","compaction","throughput"],"backgroundTag":"value-out-of-range","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}