apache/cassandra · critical · RuntimeException
Not enough space for compaction (%s) of %s.%s, estimated sst
Error message
Not enough space for compaction (%s) of %s.%s, estimated sstables = %d, expected write size = %d
What it means
Before running a compaction, Cassandra estimates the required temporary disk space (expected write size) and checks available disk. If the estimated space is not available and the compaction cannot be shrunk further, runMayThrow aborts the compaction and throws this RuntimeException so data is not written to a full disk.
Source
Thrown at src/java/org/apache/cassandra/db/compaction/CompactionTask.java:550
// but we can still remove expired SSTables
if (partialCompactionsAcceptable() && containsExpired)
{
for (SSTableReader rdr : nonExpiredSSTables)
transaction.cancel(rdr);
nonExpiredSSTables.clear();
assert transaction.originals().size() > 0;
break;
}
String msg = String.format("Not enough space for compaction (%s) of %s.%s, estimated sstables = %d, expected write size = %d",
taskId,
cfs.getKeyspaceName(),
cfs.name,
Math.max(1, writeSize / strategy.getMaxSSTableBytes()),
writeSize);
logger.warn(msg);
CompactionManager.instance.incrementAborted();
throw new RuntimeException(msg);
}
sstablesRemoved++;
logger.warn("Not enough space for compaction {}, {}MiB estimated. Reducing scope.",
taskId, (float) writeSize / 1024 / 1024);
}
if(sstablesRemoved > 0)
{
CompactionManager.instance.incrementCompactionsReduced();
CompactionManager.instance.incrementSstablesDropppedFromCompactions(sstablesRemoved);
return false;
}
return true;
}
protected int getLevel()
{View on GitHub (pinned to 88fd0f6a0e)
Solutions
- Free disk space or add capacity so free space exceeds the estimated write size
- Lower compaction throughput (concurrent_compactors / compaction_throughput) to reduce simultaneous space demands temporarily
- Run nodetool compact selectively on smaller subsets, or use nodetool garbagecollect, instead of a single huge compaction
- Reduce sstable size pressure (e.g. tune strategy maxSSTableBytes) and re-attempt
- Investigate with nodetool compactionstats and disk usage to see if pending compactions can be paced
Defensive patterns
Strategy: try-catch
Validate before calling
long writeSize = estimateCompactionWriteSize(cfs, sstables);
if (writeSize > usableFreeBytes(cfs)) throw new IllegalStateException("insufficient disk for compaction: need " + writeSize); Try / catch
try {
CompactionManager.instance.submitUserDefined(cfs, sstables, gcBefore).get();
} catch (RuntimeException e) {
if (e.getMessage() != null && e.getMessage().startsWith("Not enough space for compaction")) {
// free space / reduce scope, then retry with smaller sstable subset
} else throw e;
} Prevention
- Monitor disk usage and alert well before compaction headroom is exhausted
- Pace compaction_throughput and concurrent_compactors on large tables
- Schedule major compactions after capacity expansion, not before
- Check nodetool compactionstats for overlapping large compactions
When it happens
Trigger: A compaction of a large table (many large SSTables) is scheduled while free disk space is below the estimated write size; estimated sstable count and write size appear in the message.
Common situations: Disks near capacity during major compaction or repair-driven compactions; undersized disks after data growth; burst of concurrent compactions consuming shared space; compaction strategy with very large maxSSTableBytes creating huge write sizes.
Related errors
- Not enough space to write %s to %s (%s available)
- Not enough disk space to store %s
- No configured data directory contains enough space to write
- Interruption of compaction encountered exceptions:
- Only {} free across all data volumes. Consider adding more c
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/f7946a91c5222fa2.
Report an issue: GitHub.