{"record":{"id":"161bccce75d85b8a","repo":"apache/cassandra","slug":"corruptsstableexception-wrapping-ioexception-cause","errorCode":null,"errorMessage":"CorruptSSTableException wrapping IOException cause for ${filename}","messagePattern":"CorruptSSTableException wrapping IOException cause for (.+?)","errorType":"exception","errorClass":"CorruptSSTableException","httpStatus":null,"severity":"critical","filePath":"src/java/org/apache/cassandra/io/sstable/SSTableIdentityIterator.java","lineNumber":207,"sourceCode":"        {\n            return iterator.hasNext();\n        }\n        catch (IndexOutOfBoundsException | VIntOutOfRangeException | AssertionError e)\n        {\n            sstable.markSuspect();\n            throw new CorruptSSTableException(e, filename);\n        }\n        catch (CorruptSSTableException e) // to ensure that we marked the sstable as suspected if CorruptSSTableException is thrown from lower levels\n        {\n            sstable.markSuspect();\n            throw e;\n        }\n        catch (IOError e)\n        {\n            if (e.getCause() instanceof IOException)\n            {\n                sstable.markSuspect();\n                throw new CorruptSSTableException((Exception)e.getCause(), filename);\n            }\n            else\n            {\n                throw e;\n            }\n        }\n    }\n\n    public Unfiltered next()\n    {\n        try\n        {\n            if (isClosed)\n                throw new IllegalStateException(\"Iterator used after closing.\");\n\n            return doCompute();\n        }\n        catch (IndexOutOfBoundsException | VIntOutOfRangeException | AssertionError e)","sourceCodeStart":189,"sourceCodeEnd":225,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/io/sstable/SSTableIdentityIterator.java#L189-L225","documentation":"When iteration hits an IOError whose cause is an IOException, SSTableIdentityIterator.hasNext() treats it as disk-level corruption: it marks the sstable suspect and rethrows the cause wrapped in a CorruptSSTableException with the sstable filename. IErrors with other causes are rethrown unchanged.","triggerScenarios":"Calling hasNext() when the underlying file reader (e.g. RandomAccessReader) throws org.apache.cassandra.io.util.IOError caused by an IOException during row reads — disk read failure, file truncated beneath the reader, or compressed-file read error.","commonSituations":"Disk failure or bad sectors encountered mid-scan; sstable file deleted or truncated while queries run; storage-layer errors (NFS, EBS) surfacing as IOExceptions; corrupted compression metadata.","solutions":["Scrub the table with `nodetool scrub` to handle the corrupt sstable named in the exception","Restore the sstable from backup or run `nodetool repair` to re-stream healthy data from replicas","Check dmesg/filesystem logs for I/O errors and fix or replace the failing disk","Ensure no external process is modifying or removing sstable files while Cassandra runs"],"exampleFix":"// before: leaving node in a failing state\n// after: scrub corrupt table and repair data\nnodetool scrub -- keyspace table\nnodetool repair -- keyspace table","handlingStrategy":"try-catch","validationCode":"// ensure the file is intact and accessible before iterating\nif (!new File(filename).exists()) throw new IllegalStateException('sstable missing');\n// run nodetool verify / sstable checksums to pre-validate","typeGuard":null,"tryCatchPattern":"try {\n    while (iter.hasNext()) { consume(iter.next()); }\n} catch (CorruptSSTableException e) {\n    logger.error(\"Read failed on sstable {}: {}\", e.getPath(), e.getCause());\n    // retry on another replica; schedule scrub/repair\n} catch (IOError e) {\n    // non-IOException cause: surface as infrastructure failure\n    throw e;\n}","preventionTips":["Monitor for external processes touching the data directory","Use local healthy storage rather than unreliable network mounts","Enable regular scrubs to quarantine corrupt sstables","Keep RF>=3 and repair often","Watch disk SMART metrics"],"tags":["sstable","corruption","io","storage"],"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"}