{"record":{"id":"f7946a91c5222fa2","repo":"apache/cassandra","slug":"not-enough-space-for-compaction-s-of-s-s-est","errorCode":null,"errorMessage":"Not enough space for compaction (%s) of %s.%s, estimated sstables = %d, expected write size = %d","messagePattern":"Not enough space for compaction \\((.+?)\\) of (.+?)\\.(.+?), estimated sstables = (.+?), expected write size = (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"critical","filePath":"src/java/org/apache/cassandra/db/compaction/CompactionTask.java","lineNumber":550,"sourceCode":"                // but we can still remove expired SSTables\n                if (partialCompactionsAcceptable() && containsExpired)\n                {\n                    for (SSTableReader rdr : nonExpiredSSTables)\n                        transaction.cancel(rdr);\n                    nonExpiredSSTables.clear();\n                    assert transaction.originals().size() > 0;\n                    break;\n                }\n\n                String msg = String.format(\"Not enough space for compaction (%s) of %s.%s, estimated sstables = %d, expected write size = %d\",\n                                           taskId,\n                                           cfs.getKeyspaceName(),\n                                           cfs.name,\n                                           Math.max(1, writeSize / strategy.getMaxSSTableBytes()),\n                                           writeSize);\n                logger.warn(msg);\n                CompactionManager.instance.incrementAborted();\n                throw new RuntimeException(msg);\n            }\n\n            sstablesRemoved++;\n            logger.warn(\"Not enough space for compaction {}, {}MiB estimated. Reducing scope.\",\n                        taskId, (float) writeSize / 1024 / 1024);\n        }\n\n        if(sstablesRemoved > 0)\n        {\n            CompactionManager.instance.incrementCompactionsReduced();\n            CompactionManager.instance.incrementSstablesDropppedFromCompactions(sstablesRemoved);\n            return false;\n        }\n        return true;\n    }\n\n    protected int getLevel()\n    {","sourceCodeStart":532,"sourceCodeEnd":568,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/db/compaction/CompactionTask.java#L532-L568","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"long writeSize = estimateCompactionWriteSize(cfs, sstables);\nif (writeSize > usableFreeBytes(cfs)) throw new IllegalStateException(\"insufficient disk for compaction: need \" + writeSize);","typeGuard":null,"tryCatchPattern":"try {\n    CompactionManager.instance.submitUserDefined(cfs, sstables, gcBefore).get();\n} catch (RuntimeException e) {\n    if (e.getMessage() != null && e.getMessage().startsWith(\"Not enough space for compaction\")) {\n        // free space / reduce scope, then retry with smaller sstable subset\n    } else throw e;\n}","preventionTips":["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"],"tags":["compaction","disk-space","storage"],"backgroundTag":"insufficient-disk-space","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}