{"record":{"id":"98b85f2ea1167218","repo":"apache/cassandra","slug":"insufficient-disk-space-to-store-s-98b85f","errorCode":null,"errorMessage":"Insufficient disk space to store %s","messagePattern":"Insufficient disk space to store (.+?)","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"critical","filePath":"src/java/org/apache/cassandra/io/sstable/RangeAwareSSTableWriter.java","lineNumber":74,"sourceCode":"    public RangeAwareSSTableWriter(ColumnFamilyStore cfs, long estimatedKeys, long repairedAt, TimeUUID pendingRepair, boolean isTransient, SSTableFormat<?, ?> format, int sstableLevel, long totalSize, ILifecycleTransaction txn, SerializationHeader header) throws IOException\n    {\n        DiskBoundaries db = cfs.getDiskBoundaries();\n        directories = db.directories;\n        this.sstableLevel = sstableLevel;\n        this.cfs = cfs;\n        this.estimatedKeys = estimatedKeys / directories.size();\n        this.repairedAt = repairedAt;\n        this.pendingRepair = pendingRepair;\n        this.isTransient = isTransient;\n        this.format = format;\n        this.txn = txn;\n        this.header = header;\n        boundaries = db.positions;\n        if (boundaries == null)\n        {\n            Directories.DataDirectory localDir = cfs.getDirectories().getWriteableLocation(totalSize);\n            if (localDir == null)\n                throw new IOException(String.format(\"Insufficient disk space to store %s\",\n                                                    FBUtilities.prettyPrintMemory(totalSize)));\n            Descriptor desc = cfs.newSSTableDescriptor(cfs.getDirectories().getLocationForDisk(localDir), format);\n            currentWriter = cfs.createSSTableMultiWriter(desc, estimatedKeys, repairedAt, pendingRepair, isTransient, null, sstableLevel, header, txn);\n        }\n    }\n\n    private void maybeSwitchWriter(DecoratedKey key)\n    {\n        if (boundaries == null)\n            return;\n\n        boolean switched = false;\n        while (currentIndex < 0 || key.compareTo(boundaries.get(currentIndex)) > 0)\n        {\n            switched = true;\n            currentIndex++;\n        }\n","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/io/sstable/RangeAwareSSTableWriter.java#L56-L92","documentation":"RangeAwareSSTableWriter's constructor consults Directories.DataDirectory positions to decide where to place the new SSTable; when no data directory has enough free space for the estimated totalSize, getWriteableLocation returns null and the constructor throws IOException 'Insufficient disk space to store <pretty-printed size>'. This is the disk-space guard on the write path before any file is created.","triggerScenarios":"Creating a RangeAwareSSTableWriter (streaming, repair, or compaction-adjacent writers) when every configured data directory's usable space is below the estimated totalSize, or disk failure policy has blacklisted all volumes.","commonSituations":"Full disks during streaming/repair in large clusters; undersized test volumes; badly distributed data dirs where all candidate mounts are full.","solutions":["Free disk space or expand the data volumes on the target node, then retry the operation","Lower the data footprint (reduce replication, drop unnecessary snapshots, run cleanup/gc) before re-running streaming/repair","Add or rebalance data directories in cassandra.yaml so getWriteableLocation can find a volume with sufficient space","Check the disk failure policy configuration; a misconfigured policy can mark healthy disks unavailable"],"exampleFix":"// mitigation is operational; caller-side guard:\n// before\nRangeAwareSSTableWriter w = new RangeAwareSSTableWriter(cfs, header, totalSize, ...); // throws\n// after\nif (cfs.getDirectories().getWriteableLocation(totalSize) == null)\n    throw new IOException(\"Aborting: not enough disk space for \" + FBUtilities.prettyPrintMemory(totalSize));\nRangeAwareSSTableWriter w = new RangeAwareSSTableWriter(cfs, header, totalSize, ...);","handlingStrategy":"try-catch","validationCode":"if (cfs.getDirectories().getWriteableLocation(totalSize) == null)\n    throw new IOException(\"Insufficient disk space for \" + FBUtilities.prettyPrintMemory(totalSize));","typeGuard":null,"tryCatchPattern":"try { writer = new RangeAwareSSTableWriter(cfs, header, totalSize, ...); }\ncatch (IOException e) {\n    if (e.getMessage().startsWith(\"Insufficient disk space\"))\n        // free space, then retry or fail the stream gracefully\n}","preventionTips":["Monitor disk utilization with alerts well below capacity","Account for estimated SSTable size before streaming/repair","Keep multiple data directories with headroom; rotate snapshots and run cleanup regularly"],"tags":["disk-space","io","streaming","capacity"],"backgroundTag":"file-write-failed","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"}