{"record":{"id":"1981a207d44c14c7","repo":"apache/cassandra","slug":"disabling-compaction-by-setting-min-compaction-thr","errorCode":null,"errorMessage":"Disabling compaction by setting min_compaction_threshold or max_compaction_threshold to 0 is deprecated, set the compaction strategy option 'enabled' to 'false' instead or use the nodetool command 'disableautocompaction'.","messagePattern":"Disabling compaction by setting min_compaction_threshold or max_compaction_threshold to 0 is deprecated, set the compaction strategy option 'enabled' to 'false' instead or use the nodetool command 'disableautocompaction'\\.","errorType":"exception","errorClass":"java.lang.RuntimeException","httpStatus":null,"severity":"warning","filePath":"src/java/org/apache/cassandra/db/ColumnFamilyStore.java","lineNumber":2991,"sourceCode":"    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;\n        }\n        return count > 0 ? (int) (sum / count) : 0;\n    }\n","sourceCodeStart":2973,"sourceCodeEnd":3009,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/db/ColumnFamilyStore.java#L2973-L3009","documentation":"validateCompactionThresholds rejects setting min_compaction_threshold or max_compaction_threshold to 0, because disabling compaction via zero thresholds is deprecated. Operators must instead disable the compaction strategy (option 'enabled': 'false') or use nodetool disableautocompaction.","triggerScenarios":"setMinCompactionThreshold(0) or setMaxCompactionThreshold(0) via JMX/nodetool on a ColumnFamilyStore.","commonSituations":"Operators or scripts trying to 'pause' compaction during bulk loads using the old 0-threshold trick from pre-3.x practice; migration of old automation to newer Cassandra versions.","solutions":["Run nodetool disableautocompaction <ks> <table> instead of setting thresholds to 0","Set the compaction strategy option 'enabled' to 'false': ALTER TABLE ... WITH compaction = {'class': '...', 'enabled': 'false'}","Keep thresholds >= 1 and manage compaction pressure with strategy options"],"exampleFix":"// before\nnodetool setmincompactionthreshold ks.t 0   // deprecated -> RuntimeException\n// after\nnodetool disableautocompaction ks t  // or: ALTER TABLE ks.t WITH compaction = {'class': 'SizeTieredCompactionStrategy', 'enabled': 'false'}","handlingStrategy":"validation","validationCode":"if (minThreshold == 0 || maxThreshold == 0) throw new IllegalArgumentException(\"use 'enabled': 'false' or nodetool disableautocompaction instead of 0 thresholds\");","typeGuard":null,"tryCatchPattern":"try { cfs.setMinCompactionThreshold(0); } catch (RuntimeException e) { /* deprecated disable path: call nodetool disableautocompaction instead */ }","preventionTips":["Replace any automation that disables compaction with 0 thresholds","Use nodetool disableautocompaction/enableautocompaction for pausing compaction","Set compaction option 'enabled': 'false' for permanent disabling"],"tags":["cassandra","compaction","deprecated","jmx"],"backgroundTag":"deprecated-api-usage","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"}