{"record":{"id":"ec2f5ecbcbe06eab","repo":"apache/cassandra","slug":"the-min-compaction-threshold-cannot-be-larger-than","errorCode":null,"errorMessage":"The min_compaction_threshold cannot be larger than the max_compaction_threshold. Min is '%d', Max is '%d'.","messagePattern":"The min_compaction_threshold cannot be larger than the max_compaction_threshold\\. Min is '(.+?)', Max is '(.+?)'\\.","errorType":"exception","errorClass":"java.lang.RuntimeException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/db/ColumnFamilyStore.java","lineNumber":2987,"sourceCode":"        validateCompactionThresholds(minCompactionThreshold, maxCompactionThreshold.value());\n        this.minCompactionThreshold.set(minCompactionThreshold);\n    }\n\n    public int getMaximumCompactionThreshold()\n    {\n        return maxCompactionThreshold.value();\n    }\n\n    public void setMaximumCompactionThreshold(int maxCompactionThreshold)\n    {\n        validateCompactionThresholds(minCompactionThreshold.value(), maxCompactionThreshold);\n        this.maxCompactionThreshold.set(maxCompactionThreshold);\n    }\n\n    private void validateCompactionThresholds(int minThreshold, int maxThreshold)\n    {\n        if (minThreshold > maxThreshold)\n            throw new RuntimeException(String.format(\"The min_compaction_threshold cannot be larger than the max_compaction_threshold. \" +\n                                                     \"Min is '%d', Max is '%d'.\", minThreshold, maxThreshold));\n\n        if (maxThreshold == 0 || minThreshold == 0)\n            throw new RuntimeException(\"Disabling compaction by setting min_compaction_threshold or max_compaction_threshold to 0 \" +\n                                       \"is deprecated, set the compaction strategy option 'enabled' to 'false' instead or use the nodetool command 'disableautocompaction'.\");\n    }\n\n    // End JMX get/set.\n\n    public int getMeanEstimatedCellPerPartitionCount()\n    {\n        long sum = 0;\n        long count = 0;\n        for (SSTableReader sstable : getSSTables(SSTableSet.CANONICAL))\n        {\n            long n = sstable.getEstimatedCellPerPartitionCount().count();\n            sum += sstable.getEstimatedCellPerPartitionCount().mean() * n;\n            count += n;","sourceCodeStart":2969,"sourceCodeEnd":3005,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/db/ColumnFamilyStore.java#L2969-L3005","documentation":"validateCompactionThresholds enforces that min_compaction_threshold is not larger than max_compaction_threshold and throws RuntimeException when violated. This guards JMX-based threshold updates (setMinCompactionThreshold/setMaxCompactionThreshold path) from producing a nonsensical compaction configuration.","triggerScenarios":"Calling setMinCompactionThreshold or setMaxCompactionThreshold (JMX/nodetool) such that the resulting min > max, e.g. raising min above the existing max without raising max first.","commonSituations":"Operators raising min threshold to reduce compaction churn without touching max; automation setting only one of the two thresholds.","solutions":["Raise max_compaction_threshold first (or simultaneously) so max >= min","Lower min_compaction_threshold instead if the intent is fewer/smaller compactions","Use the preferred configuration route: ALTER TABLE ... WITH compaction = {'class': '...', 'min_threshold': 4, 'max_threshold': 32} which validates atomically"],"exampleFix":"// before\nnodetool setmincompactionthreshold ks.t 64   // min(64) > max(32) -> RuntimeException\n// after\nnodetool setmaxcompactionthreshold ks.t 64 && nodetool setmincompactionthreshold ks.t 64","handlingStrategy":"validation","validationCode":"if (minThreshold > maxThreshold) throw new IllegalArgumentException(\"min_compaction_threshold must be <= max_compaction_threshold\");","typeGuard":null,"tryCatchPattern":"try { cfs.setMinCompactionThreshold(min); } catch (RuntimeException e) { if (e.getMessage().startsWith(\"The min_compaction_threshold\")) { cfs.setMaxCompactionThreshold(min); cfs.setMinCompactionThreshold(min); } else throw e; }","preventionTips":["Always set max before (or with) raising min","Read both current thresholds before updating either one","Prefer a single ALTER TABLE WITH compaction = {...} to change both atomically"],"tags":["cassandra","compaction","jmx","thresholds"],"backgroundTag":"conflicting-config-options","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}