{"record":{"id":"4e58dca5edfd6369","repo":"apache/cassandra","slug":"min-compaction-threshold-cannot-be-less-than-2-go","errorCode":null,"errorMessage":"Min compaction threshold cannot be less than 2 (got %d)","messagePattern":"Min compaction threshold cannot be less than 2 \\(got (.+?)\\)","errorType":"validation","errorClass":"ConfigurationException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/schema/CompactionParams.java","lineNumber":254,"sourceCode":"        }\n\n        String maxThreshold = options.get(Option.MAX_THRESHOLD.toString());\n        if (maxThreshold != null && !StringUtils.isNumeric(maxThreshold))\n        {\n            throw new ConfigurationException(format(\"Invalid value %s for '%s' compaction sub-option - must be an integer\",\n                                                    maxThreshold,\n                                                    Option.MAX_THRESHOLD));\n        }\n\n        if (minCompactionThreshold() <= 0 || maxCompactionThreshold() <= 0)\n        {\n            throw new ConfigurationException(\"Disabling compaction by setting compaction thresholds to 0 has been removed,\"\n                                             + \" set the compaction option 'enabled' to false instead.\");\n        }\n\n        if (minCompactionThreshold() <= 1)\n        {\n            throw new ConfigurationException(format(\"Min compaction threshold cannot be less than 2 (got %d)\",\n                                                    minCompactionThreshold()));\n        }\n\n        if (minCompactionThreshold() > maxCompactionThreshold())\n        {\n            throw new ConfigurationException(format(\"Min compaction threshold (got %d) cannot be greater than max compaction threshold (got %d)\",\n                                                    minCompactionThreshold(),\n                                                    maxCompactionThreshold()));\n        }\n    }\n\n    double defaultBloomFilterFbChance()\n    {\n        return klass.equals(LeveledCompactionStrategy.class) ? 0.1 : 0.01;\n    }\n\n    public Class<? extends AbstractCompactionStrategy> klass()\n    {","sourceCodeStart":236,"sourceCodeEnd":272,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/schema/CompactionParams.java#L236-L272","documentation":"Cassandra requires the min compaction threshold to be at least 2. validate() rejects min_threshold values of 1 or lower with a ConfigurationException, since a single-SSTable minimum makes tiered compaction behavior meaningless.","triggerScenarios":"ALTER TABLE ... WITH compaction = {'class': '...', 'min_threshold': '1'}; programmatic setCompactionParameters with min_threshold <= 1.","commonSituations":"Operators trying to force aggressive compaction by lowering min_threshold to 1; copying settings from non-Cassandra systems.","solutions":["Set min_threshold to 2 or higher, e.g. {'min_threshold': '4'}","If the goal is faster compaction, tune max_threshold or the strategy class instead of dropping min below 2","Validate the threshold range in client tooling before submitting schema changes"],"exampleFix":"// before\ncompaction = {'class': 'SizeTieredCompactionStrategy', 'min_threshold': '1'}\n// after\ncompaction = {'class': 'SizeTieredCompactionStrategy', 'min_threshold': '4'}","handlingStrategy":"validation","validationCode":"int min = Integer.parseInt(opts.getOrDefault(\"min_threshold\", \"4\"));\nif (min <= 1) throw new IllegalArgumentException(\"min_threshold must be >= 2\");","typeGuard":null,"tryCatchPattern":"try { schemaChange(ddl); } catch (ConfigurationException e) { if (e.getMessage().contains(\"cannot be less than 2\")) { /* raise min_threshold */ } throw e; }","preventionTips":["Keep min_threshold >= 2 in all compaction configs","Cross-check ops playbooks that suggest min=1","Validate ranges in config generators"],"tags":["cassandra","configuration","compaction"],"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-17T15:17:12.973Z"}