apache/cassandra · error · java.lang.RuntimeException
The min_compaction_threshold cannot be larger than the max_c
Error message
The min_compaction_threshold cannot be larger than the max_compaction_threshold. Min is '%d', Max is '%d'.
What it means
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.
Source
Thrown at src/java/org/apache/cassandra/db/ColumnFamilyStore.java:2987
validateCompactionThresholds(minCompactionThreshold, maxCompactionThreshold.value());
this.minCompactionThreshold.set(minCompactionThreshold);
}
public int getMaximumCompactionThreshold()
{
return maxCompactionThreshold.value();
}
public void setMaximumCompactionThreshold(int maxCompactionThreshold)
{
validateCompactionThresholds(minCompactionThreshold.value(), maxCompactionThreshold);
this.maxCompactionThreshold.set(maxCompactionThreshold);
}
private void validateCompactionThresholds(int minThreshold, int maxThreshold)
{
if (minThreshold > maxThreshold)
throw new RuntimeException(String.format("The min_compaction_threshold cannot be larger than the max_compaction_threshold. " +
"Min is '%d', Max is '%d'.", minThreshold, maxThreshold));
if (maxThreshold == 0 || minThreshold == 0)
throw new RuntimeException("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'.");
}
// End JMX get/set.
public int getMeanEstimatedCellPerPartitionCount()
{
long sum = 0;
long count = 0;
for (SSTableReader sstable : getSSTables(SSTableSet.CANONICAL))
{
long n = sstable.getEstimatedCellPerPartitionCount().count();
sum += sstable.getEstimatedCellPerPartitionCount().mean() * n;
count += n;View on GitHub (pinned to 88fd0f6a0e)
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
Example fix
// before nodetool setmincompactionthreshold ks.t 64 // min(64) > max(32) -> RuntimeException // after nodetool setmaxcompactionthreshold ks.t 64 && nodetool setmincompactionthreshold ks.t 64
Defensive patterns
Strategy: validation
Validate before calling
if (minThreshold > maxThreshold) throw new IllegalArgumentException("min_compaction_threshold must be <= max_compaction_threshold"); Try / catch
try { cfs.setMinCompactionThreshold(min); } catch (RuntimeException e) { if (e.getMessage().startsWith("The min_compaction_threshold")) { cfs.setMaxCompactionThreshold(min); cfs.setMinCompactionThreshold(min); } else throw e; } Prevention
- 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
When it happens
Trigger: Calling setMinCompactionThreshold or setMaxCompactionThreshold (JMX/nodetool) such that the resulting min > max, e.g. raising min above the existing max without raising max first.
Common situations: Operators raising min threshold to reduce compaction churn without touching max; automation setting only one of the two thresholds.
Understand the failure class
Background: Conflicting config options: "cannot be used together" — configuration validation errors across open-source libraries — this error's family across 162 libraries.
Related errors
- Could not set new local compaction strategy: <cause message>
- Disabling compaction by setting min_compaction_threshold or
- %s is not a valid JMX resource name
- JAAS login configuration missing for JMX authenticator setup
- Authentication error
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/ec2f5ecbcbe06eab.
Report an issue: GitHub.