{"record":{"id":"3ec06a814f0a84bc","repo":"apache/cassandra","slug":"min-compaction-threshold-got-d-cannot-be-greate","errorCode":null,"errorMessage":"Min compaction threshold (got %d) cannot be greater than max compaction threshold (got %d)","messagePattern":"Min compaction threshold \\(got (.+?)\\) cannot be greater than max compaction threshold \\(got (.+?)\\)","errorType":"validation","errorClass":"ConfigurationException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/schema/CompactionParams.java","lineNumber":260,"sourceCode":"                                                    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    {\n        return klass;\n    }\n\n    /**\n     * All strategy options - excluding 'class'.\n     */","sourceCodeStart":242,"sourceCodeEnd":278,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/schema/CompactionParams.java#L242-L278","documentation":"Fired in CompactionParams.validate (reached via ALTER TABLE ... WITH compaction or table creation options): min_compaction_threshold exceeds max_compaction_threshold, an invalid combination since min must be <= max (and both positive). Thrown as ConfigurationException during compaction option validation.","triggerScenarios":"Schema changes like {'min_threshold': '32', 'max_threshold': '4'}; programmatic option maps where the values are swapped or computed independently without cross-checking.","commonSituations":"Bulk schema edits that set one threshold but forget the other; automation that computes thresholds from metrics without sanity checks.","solutions":["Set max_threshold >= min_threshold, e.g. {'min_threshold': '4', 'max_threshold': '32'}","Re-check which value is which; the values are often accidentally swapped","Add pre-submission validation: reject any option map where min > max"],"exampleFix":"// before\ncompaction = {'class': 'SizeTieredCompactionStrategy', 'min_threshold': '32', 'max_threshold': '4'}\n// after\ncompaction = {'class': 'SizeTieredCompactionStrategy', 'min_threshold': '4', 'max_threshold': '32'}","handlingStrategy":"validation","validationCode":"int min = Integer.parseInt(opts.getOrDefault(\"min_threshold\", \"4\"));\nint max = Integer.parseInt(opts.getOrDefault(\"max_threshold\", \"32\"));\nif (min > max) throw new IllegalArgumentException(\"min_threshold must be <= max_threshold\");","typeGuard":null,"tryCatchPattern":"try { schemaChange(ddl); } catch (ConfigurationException e) { if (e.getMessage().contains(\"cannot be greater than max\")) { /* swap/correct thresholds */ } throw e; }","preventionTips":["Always set min and max thresholds together with min <= max","Add a sanity assertion wherever thresholds are computed programmatically","Avoid independent config keys that can drift apart"],"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"}