{"record":{"id":"74b3d3a935a66599","repo":"apache/cassandra","slug":"fswriteerror-74b3d3","errorCode":null,"errorMessage":"FSWriteError","messagePattern":"FSWriteError","errorType":"exception","errorClass":"FSWriteError","httpStatus":null,"severity":"critical","filePath":"src/java/org/apache/cassandra/io/compress/CompressedSequentialWriter.java","lineNumber":271,"sourceCode":"            buffer.position(uncompressedLength);\n\n        // next chunk should be written right after current + length of the checksum (int)\n        chunkOffset += compressedLength + 4;\n        if (runPostFlush != null)\n            runPostFlush.accept(getLastFlushOffset());\n    }\n\n    protected void writeChunk(ByteBuffer toWrite)\n    {\n        try\n        {\n            channel.write(toWrite);\n            toWrite.rewind();\n            crcMetadata.appendDirect(toWrite, true);\n        }\n        catch (IOException e)\n        {\n            throw new FSWriteError(e, getPath());\n        }\n    }\n\n    public CompressionMetadata open(long overrideLength)\n    {\n        if (overrideLength <= 0)\n            overrideLength = uncompressedSize;\n        return metadataWriter.open(overrideLength, chunkOffset);\n    }\n\n    @Override\n    public DataPosition mark()\n    {\n        if (!buffer.hasRemaining())\n            doFlush(0);\n        return new CompressedFileWriterMark(chunkOffset, current(), buffer.position(), chunkCount + 1);\n    }\n","sourceCodeStart":253,"sourceCodeEnd":289,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/io/compress/CompressedSequentialWriter.java#L253-L289","documentation":"writeChunk() writes a compressed chunk to the file channel and appends its CRC. Any IOException from channel.write() (or the CRC metadata append) is wrapped in FSWriteError with the file path, failing the write operation because partial chunk writes would corrupt the compressed SSTable layout.","triggerScenarios":"flushData() -> writeChunk() when the disk is full (ENOSPC), the device returns EIO, the filesystem is read-only, or the channel was closed while writing compressed SSTable data during flush or compaction.","commonSituations":"Disk full during a large memtable flush; failed/remounted volumes in containers; quota-limited storage hitting capacity mid-write; concurrent closure of the channel after a disk swap.","solutions":["Free disk space or expand the volume; Cassandra retries the failed flush after space is available","Check the wrapped IOException cause in the log for the specific errno (ENOSPC/EIO/EBADF) and fix the underlying storage","Verify filesystem is writable and permissions/ownership on the data directories are correct for the Cassandra user","After disk recovery, validate/rebuild affected SSTables with nodetool scrub"],"exampleFix":"// before\n# df -h /var/lib/cassandra -> 100% full, flush throws FSWriteError\n// after\n# expand volume or move data dirs; ensure free space\ndf -h /var/lib/cassandra\nnodetool scrub ks tbl","handlingStrategy":"retry","validationCode":"// Pre-flight checks before heavy writes\nif (Files.getFileStore(Paths.get(dataDir)).getUsableSpace() < requiredBytes) throw new IllegalStateException(\"insufficient disk\");\nif (!Files.isWritable(Paths.get(dataDir))) throw new IllegalStateException(\"data dir not writable\");","typeGuard":null,"tryCatchPattern":"try {\n    flushData();\n} catch (FSWriteError e) {\n    logger.error(\"Chunk write failed for {}\", e.getPath(), e.getCause());\n    // free disk / fix storage, then retry flush; Cassandra retries automatically on the next flush attempt\n}","preventionTips":["Keep data volumes below ~80% utilization with alerting at that threshold","Verify directory permissions/ownership after any storage migration","Monitor write latencies and I/O errors on data disks","Avoid running nodes on read-only or quota-limited filesystems"],"tags":["io","filesystem","compressed-writer","disk-full"],"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"}