apache/cassandra · warning · java.lang.RuntimeException
Disabling compaction by setting min_compaction_threshold or
Error message
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'.
What it means
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.
Source
Thrown at src/java/org/apache/cassandra/db/ColumnFamilyStore.java:2991
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;
}
return count > 0 ? (int) (sum / count) : 0;
}
View on GitHub (pinned to 88fd0f6a0e)
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
Example fix
// before
nodetool setmincompactionthreshold ks.t 0 // deprecated -> RuntimeException
// after
nodetool disableautocompaction ks t // or: ALTER TABLE ks.t WITH compaction = {'class': 'SizeTieredCompactionStrategy', 'enabled': 'false'} Defensive patterns
Strategy: validation
Validate before calling
if (minThreshold == 0 || maxThreshold == 0) throw new IllegalArgumentException("use 'enabled': 'false' or nodetool disableautocompaction instead of 0 thresholds"); Try / catch
try { cfs.setMinCompactionThreshold(0); } catch (RuntimeException e) { /* deprecated disable path: call nodetool disableautocompaction instead */ } Prevention
- Replace any automation that disables compaction with 0 thresholds
- Use nodetool disableautocompaction/enableautocompaction for pausing compaction
- Set compaction option 'enabled': 'false' for permanent disabling
When it happens
Trigger: setMinCompactionThreshold(0) or setMaxCompactionThreshold(0) via JMX/nodetool on a ColumnFamilyStore.
Common situations: 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.
Understand the failure class
Background: "is deprecated and will be removed" — deprecation warnings for old API names, keywords, and options, and how to migrate before the removal release — this error's family across 29 libraries.
Related errors
- Could not set new local compaction strategy: <cause message>
- The min_compaction_threshold cannot be larger than the max_c
- Disabling compaction by setting compaction thresholds to 0 h
- Unknown endpoint %s
- %s is not a valid JMX resource name
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/1981a207d44c14c7.
Report an issue: GitHub.