apache/cassandra · error · ConfigurationException

Min compaction threshold cannot be less than 2

Error message

Min compaction threshold cannot be less than 2 (got %d)

What it means

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.

Solutions

  1. Set min_threshold to 2 or higher, e.g. {'min_threshold': '4'}
  2. If the goal is faster compaction, tune max_threshold or the strategy class instead of dropping min below 2
  3. Validate the threshold range in client tooling before submitting schema changes

Example fix

// before
compaction = {'class': 'SizeTieredCompactionStrategy', 'min_threshold': '1'}
// after
compaction = {'class': 'SizeTieredCompactionStrategy', 'min_threshold': '4'}
Defensive patterns

Strategy: validation

Validate before calling

int min = Integer.parseInt(opts.getOrDefault("min_threshold", "4"));
if (min <= 1) throw new IllegalArgumentException("min_threshold must be >= 2");

Try / catch

try { schemaChange(ddl); } catch (ConfigurationException e) { if (e.getMessage().contains("cannot be less than 2")) { /* raise min_threshold */ } throw e; }

Prevention

When it happens

Trigger: ALTER TABLE ... WITH compaction = {'class': '...', 'min_threshold': '1'}; programmatic setCompactionParameters with min_threshold <= 1.

Common situations: Operators trying to force aggressive compaction by lowering min_threshold to 1; copying settings from non-Cassandra systems.

Understand the failure class

Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.

Related errors


AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10). Data as JSON: /api/errors/4e58dca5edfd6369. Report an issue: GitHub.

Appendix: source

Thrown at src/java/org/apache/cassandra/schema/CompactionParams.java:254

        }

        String maxThreshold = options.get(Option.MAX_THRESHOLD.toString());
        if (maxThreshold != null && !StringUtils.isNumeric(maxThreshold))
        {
            throw new ConfigurationException(format("Invalid value %s for '%s' compaction sub-option - must be an integer",
                                                    maxThreshold,
                                                    Option.MAX_THRESHOLD));
        }

        if (minCompactionThreshold() <= 0 || maxCompactionThreshold() <= 0)
        {
            throw new ConfigurationException("Disabling compaction by setting compaction thresholds to 0 has been removed,"
                                             + " set the compaction option 'enabled' to false instead.");
        }

        if (minCompactionThreshold() <= 1)
        {
            throw new ConfigurationException(format("Min compaction threshold cannot be less than 2 (got %d)",
                                                    minCompactionThreshold()));
        }

        if (minCompactionThreshold() > maxCompactionThreshold())
        {
            throw new ConfigurationException(format("Min compaction threshold (got %d) cannot be greater than max compaction threshold (got %d)",
                                                    minCompactionThreshold(),
                                                    maxCompactionThreshold()));
        }
    }

    double defaultBloomFilterFbChance()
    {
        return klass.equals(LeveledCompactionStrategy.class) ? 0.1 : 0.01;
    }

    public Class<? extends AbstractCompactionStrategy> klass()
    {

View on GitHub (pinned to 88fd0f6a0e)