apache/cassandra · error · IllegalArgumentException

Invalid compaction strategy:

Error message

Invalid compaction strategy: 

What it means

OptionCompaction validates the compaction strategy class name by resolving it through CompactionParams.classFromName, which throws ConfigurationException for unknown classes. The option converts this into an IllegalArgumentException 'Invalid compaction strategy: <name>' so the CLI reports an actionable message.

Solutions

  1. Use a fully qualified valid strategy class, e.g. org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy
  2. Check spelling and casing of the strategy class name
  3. Verify the strategy exists in the Cassandra version being targeted (some strategies were added/removed across versions)

Example fix

// before
-compaction strategy=LeveledStrategy
// after
-compaction strategy=org.apache.cassandra.db.compaction.LeveledCompactionStrategy
Defensive patterns

Strategy: validation

Validate before calling

try { CompactionParams.classFromName(strategyName); } catch (ConfigurationException e) { /* invalid strategy */ }

Try / catch

try { applyCompaction(name); } catch (IllegalArgumentException e) { log.error("Bad compaction strategy '{}': use a fully qualified ICompactionStrategy class", name); }

Prevention

When it happens

Trigger: Passing -compaction 'strategy=BadStrategy' or a strategy class name that is not on the classpath / not a valid ICompactionStrategy implementation to a stress command.

Common situations: Misspelled strategy names (e.g. 'SizeTieredCompactonStrategy'); using strategy names from a newer/older Cassandra version that no longer exist; custom strategies not shipped on the stress client's classpath.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


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

Appendix: source

Thrown at tools/stress/src/org/apache/cassandra/stress/settings/OptionCompaction.java:74

    @Override
    public boolean happy()
    {
        return true;
    }

    private static final class StrategyAdapter implements Function<String, String>
    {

        public String apply(String name)
        {
            try
            {
                CompactionParams.classFromName(name);
            }
            catch (ConfigurationException e)
            {
                throw new IllegalArgumentException("Invalid compaction strategy: " + name);
            }
            return name;
        }
    }

}

View on GitHub (pinned to 88fd0f6a0e)