{"record":{"id":"e8d63225d6b90347","repo":"apache/cassandra","slug":"fsreaderror-e8d632","errorCode":null,"errorMessage":"FSReadError","messagePattern":"FSReadError","errorType":"exception","errorClass":"FSReadError","httpStatus":null,"severity":"critical","filePath":"src/java/org/apache/cassandra/io/compress/CompressedSequentialWriter.java","lineNumber":179,"sourceCode":"    /**\n     * Creates the {@link ChecksumWriter} for the chunk and full-file checksums. Invoked from the constructor,\n     * so overrides must not read subclass fields.\n     */\n    protected ChecksumWriter createChecksumWriter()\n    {\n        return new ChecksumWriter(new DataOutputStream(Channels.newOutputStream(channel)));\n    }\n\n    @Override\n    public long getOnDiskFilePointer()\n    {\n        try\n        {\n            return fchannel.position();\n        }\n        catch (IOException e)\n        {\n            throw new FSReadError(e, getPath());\n        }\n    }\n\n    /**\n     * Get a quick estimation on how many bytes have been written to disk\n     *\n     * It should for the most part be exactly the same as getOnDiskFilePointer()\n     */\n    @Override\n    public long getEstimatedOnDiskBytesWritten()\n    {\n        return chunkOffset;\n    }\n\n    @Override\n    public void flush()\n    {\n        throw new UnsupportedOperationException();","sourceCodeStart":161,"sourceCodeEnd":197,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/io/compress/CompressedSequentialWriter.java#L161-L197","documentation":"CompressedSequentialWriter needs the current file channel position (e.g. to align to a compression chunk start). If the underlying FileChannel.position() call fails with an IOException, the writer wraps it in FSReadError carrying the file path, aborting the write because the on-disk position is essential to compressed chunk bookkeeping.","triggerScenarios":"Calling getOnDiskFilePointer()/seekToChunkStart() on a CompressedSequentialWriter whose file channel is broken: disk I/O error, file descriptor closed or invalidated (e.g. disk replaced, handle closed by another thread), or an OS-level error reading the channel's offset.","commonSituations":"Disk hardware failures or full/failed volumes during compaction or memtable flush; file handles closed unexpectedly after a disk swap; container environments where the storage backing SSTables becomes unavailable mid-write.","solutions":["Check the node/system logs and the wrapped IOException cause for the real OS error (EIO, EBADF, ENOSPC)","Verify the data/commitlog disk health (dmesg, smartctl) and fix or replace the failing volume","Run nodetool scrub/verify on affected SSTables and let failed flushes retry after the disk is healthy","If it stems from a closed-channel bug, check for concurrent close of the writer and serialize writer lifecycle per file"],"exampleFix":"// before\n// disk swapped under a live node -> fchannel.position() throws IOException -> FSReadError\n// after\n// ensure stable storage and run:\nnodetool drain\n# fix/replace disk, restart Cassandra; failed SSTables recovered via scrub\nnodetool scrub ks tbl","handlingStrategy":"retry","validationCode":"// Before writes, verify the data volume is healthy and writable\nFiles.isWritable(Paths.get(cassandraDataDir));\n# dmesg | grep -i 'I/O error'","typeGuard":null,"tryCatchPattern":"try {\n    writer.getOnDiskFilePointer();\n} catch (FSReadError e) {\n    logger.error(\"Channel position failed for {}\", e.getPath(), e.getCause());\n    // fail the write; let Cassandra's flush executor retry after disk recovery\n}","preventionTips":["Monitor disk health proactively (SMART metrics) on data volumes","Never close or swap files under a live writer concurrently","Set alerts for ENOSPC and I/O errors well before capacity is exhausted","Use redundant/failure-tested storage for SSTable directories"],"tags":["io","filesystem","compressed-writer","disk"],"backgroundTag":"file-read-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"}