apache/cassandra · error · IllegalStateException
CompactionStress does not support secondary indexes
Error message
CompactionStress does not support secondary indexes
What it means
CompactionStress loads existing SSTables into a ColumnFamilyStore so compaction strategies can be exercised offline. It explicitly skips registering the SSTables with any indexes; if the loaded table already has secondary indexes defined (indexManager.hasIndexes()), the tool throws IllegalStateException because compaction-stress cannot reproduce index-driven behavior and would produce misleading results. This is a deliberate unsupported-feature guard, not a corruption indicator.
Source
Thrown at tools/stress/src/org/apache/cassandra/stress/CompactionStress.java:160
continue;
try
{
SSTableReader sstable = SSTableReader.openNoValidation(entry.getKey(), components, cfs);
sstables.add(sstable);
}
catch (Exception e)
{
JVMStabilityInspector.inspectThrowable(e);
System.err.println(String.format("Error Loading %s: %s", entry.getKey(), e.getMessage()));
}
}
cfs.disableAutoCompaction();
// We want to add the SSTables without firing their indexing by any eventual unsupported 2i
if (cfs.indexManager.hasIndexes())
throw new IllegalStateException("CompactionStress does not support secondary indexes");
//Register with cfs
cfs.addSSTables(sstables);
}
return cfs;
}
StressProfile getStressProfile()
{
try
{
File yamlFile = new File(profile);
return StressProfile.load(yamlFile.exists() ? yamlFile.toURI() : URI.create(profile));
}
catch ( IOError e)
{
e.printStackTrace();View on GitHub (pinned to 88fd0f6a0e)
Solutions
- Remove or drop the secondary indexes from the schema used for the stress run (edit the schema DDL / options provided to compactionstress).
- Run compactionstress on a copy of the table whose schema has no indexes defined.
- If you need to test index compaction behavior, use a full cluster with real writes instead of compactionstress.
- Wrap the invocation to catch IllegalStateException and print guidance that 2i tables are unsupported.
Example fix
// before CREATE TABLE ks.t (k int PRIMARY KEY, v text); CREATE INDEX t_v_idx ON ks.t (v); // after CREATE TABLE ks.t (k int PRIMARY KEY, v text); // no index for compactionstress
Defensive patterns
Strategy: try-catch
Validate before calling
// before running compactionstress, inspect schema for indexes:
// cqlsh -e "DESCRIBE TABLE ks.t" | grep -i "CREATE INDEX"
boolean hasIndexes = schemaDDL.toUpperCase().contains("CREATE INDEX");
if (hasIndexes) throw new IllegalStateException("compactionstress unsupported for indexed tables"); Try / catch
try {
compactionStress.initCf(...);
} catch (IllegalStateException e) {
if (e.getMessage().contains("secondary indexes")) {
System.err.println("Drop indexes from the schema or use a full cluster for this table.");
return;
}
throw e;
} Prevention
- Strip CREATE INDEX statements from schemas used with compactionstress.
- Document that compactionstress supports only plain (non-indexed) tables.
- Snapshot production schemas into a sanitized DDL before offline testing.
When it happens
Trigger: Running compactionstress against a table (schema loaded from the sstable's schema or a provided schema) that has secondary indexes defined, i.e. cfs.indexManager.hasIndexes() returns true after the SSTables are inspected in initCf.
Common situations: Pointing compactionstress at SSTables dumped from a production table that has 2i/SAI indexes defined in its schema; forgetting that indexes are part of the table schema even if the dumped files contain no index data.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- Unsupported disk access mode for compaction_read_disk_access
- concurrent_compactors should be strictly greater than 0, but
- Invalid value of compaction_throughput:
- compaction_throughput: is too large; it should be less than
- max_concurrent_automatic_sstable_upgrades can't be negative
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/afb01b8ecffdaa30.
Report an issue: GitHub.