{"record":{"id":"64069ba92e3ad742","repo":"apache/cassandra","slug":"not-enough-disk-space-to-store-s","errorCode":null,"errorMessage":"Not enough disk space to store %s","messagePattern":"Not enough disk space to store (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"critical","filePath":"src/java/org/apache/cassandra/db/compaction/writers/CompactionAwareWriter.java","lineNumber":302,"sourceCode":"                logger.trace(\"All sstables not from the same disk - putting results in {}\", descriptor.directory);\n                break;\n            }\n        }\n        Directories.DataDirectory d = getDirectories().getDataDirectoryForFile(descriptor);\n        if (d != null)\n        {\n            long availableSpace = d.getAvailableSpace();\n            if (availableSpace < estimatedWriteSize)\n                throw new RuntimeException(String.format(\"Not enough space to write %s to %s (%s available)\",\n                                                         FBUtilities.prettyPrintMemory(estimatedWriteSize),\n                                                         d.location,\n                                                         FBUtilities.prettyPrintMemory(availableSpace)));\n            logger.trace(\"putting compaction results in {}\", descriptor.directory);\n            return d;\n        }\n        d = getDirectories().getWriteableLocation(estimatedWriteSize);\n        if (d == null)\n            throw new RuntimeException(String.format(\"Not enough disk space to store %s\",\n                                                     FBUtilities.prettyPrintMemory(estimatedWriteSize)));\n        return d;\n    }\n\n    public CompactionAwareWriter setRepairedAt(long repairedAt)\n    {\n        this.sstableWriter.setRepairedAt(repairedAt);\n        return this;\n    }\n\n    protected long getExpectedWriteSize()\n    {\n        return cfs.getExpectedCompactedFileSize(nonExpiredSSTables, txn.opType());\n    }\n\n    /**\n     * It is up to the caller to set the following fields:\n     * - {@link SSTableWriter.Builder#setKeyCount(long)},","sourceCodeStart":284,"sourceCodeEnd":320,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/db/compaction/writers/CompactionAwareWriter.java#L284-L320","documentation":"If no specific directory was determined for the descriptor, getWriteDirectory asks Directories.getWriteableLocation(estimatedWriteSize) for any data directory with enough free space. A null return (no directory can hold the estimated output) triggers a RuntimeException stating the required size. This prevents starting a compaction that would inevitably fail mid-write.","triggerScenarios":"A compaction calls defaultLocation -> getWriteDirectory when no data directory has at least estimatedWriteSize free (all disks below the blacklisting threshold for the requested size).","commonSituations":"Cluster-wide disk pressure, one-node disks filled by hints/snapshots, or very large estimated output after a burst of writes.","solutions":["Free space across data directories: drop unneeded snapshots, run nodetool cleanup, truncate/TTL-expire data.","Add storage capacity or additional data directories.","Lower estimated write pressure by tuning compaction strategy (smaller compaction targets).","Check disk_usage settings and monitoring to catch trends before writes fail."],"exampleFix":"// before (shell)\n# all data dirs < estimatedWriteSize free; compaction throws\n// after (shell)\nnodetool clearsnapshot --all && df -h /var/lib/cassandra  # verify free space before retrying","handlingStrategy":"try-catch","validationCode":"// cluster check before heavy compaction\nfor (String dir : dataDirs) if (new File(dir).getUsableSpace() < minRequiredBytes) alert();","typeGuard":null,"tryCatchPattern":"try {\n    compact();\n} catch (RuntimeException e) {\n    if (e.getMessage().startsWith(\"Not enough disk space\")) { scaleStorage(); }\n    else throw e;\n}","preventionTips":["Set and monitor disk_usage_percent_warn/fail thresholds","Automate snapshot cleanup and TTL enforcement","Provision headroom (e.g. keep <70% disk utilization) so compaction spikes fit"],"tags":["cassandra","disk-space","compaction","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"}