{"record":{"id":"9f97db56ed563285","repo":"apache/cassandra","slug":"corruptsstableexception-wrapping-ioexception-for","errorCode":null,"errorMessage":"CorruptSSTableException wrapping IOException for ${path}","messagePattern":"CorruptSSTableException wrapping IOException for (.+?)","errorType":"exception","errorClass":"CorruptSSTableException","httpStatus":null,"severity":"critical","filePath":"src/java/org/apache/cassandra/io/sstable/SSTableIdentityIterator.java","lineNumber":82,"sourceCode":"    {\n        return create(sstable, sstable.metadata(), file, key);\n    }\n\n    public static SSTableIdentityIterator create(SSTableReader sstable, TableMetadata tableMetadata, RandomAccessReader file, DecoratedKey key)\n    {\n        try\n        {\n            DeletionTime partitionLevelDeletion = DeletionTime.getSerializer(sstable.descriptor.version).deserialize(file);\n            if (!partitionLevelDeletion.validate())\n                UnfilteredValidation.handleInvalid(tableMetadata, key, sstable, \"partitionLevelDeletion=\"+partitionLevelDeletion.toString());\n            DeserializationHelper helper = new DeserializationHelper(tableMetadata, sstable.descriptor.version.correspondingMessagingVersion(), DeserializationHelper.Flag.LOCAL);\n            SSTableSimpleIterator iterator = SSTableSimpleIterator.create(tableMetadata, file, sstable.header, helper, partitionLevelDeletion);\n            return new SSTableIdentityIterator(sstable, key, partitionLevelDeletion, file.getPath(), iterator);\n        }\n        catch (IOException e)\n        {\n            sstable.markSuspect();\n            throw new CorruptSSTableException(e, file.getPath());\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    }\n\n    public static SSTableIdentityIterator create(SSTableReader sstable, FileDataInput dfile, long dataPosition, DecoratedKey key, boolean tombstoneOnly)\n    {\n        return create(sstable, sstable.metadata(), dfile, dataPosition, key, tombstoneOnly);\n    }\n\n    public static SSTableIdentityIterator create(SSTableReader sstable, TableMetadata tableMetadata, FileDataInput dfile, long dataPosition, DecoratedKey key, boolean tombstoneOnly)\n    {\n        try\n        {\n            dfile.seek(dataPosition);","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/io/sstable/SSTableIdentityIterator.java#L64-L100","documentation":"SSTableIdentityIterator.create() reads a partition's rows from an SSTable data file. If any IOException occurs while parsing the file, the sstable is marked suspect and the IOException is wrapped in a CorruptSSTableException carrying the file path. This is Cassandra's standard signal that the on-disk SSTable data could not be read or is structurally damaged.","triggerScenarios":"Calling SSTableIdentityIterator.create(tableMetadata, sstable, key, file, partitionLevelDeletion) when the underlying data file throws an IOException during SSTableSimpleIterator parsing: truncated file, bad read from a compressed or uncompressed RandomAccessReader, or I/O failure from the disk during iteration setup.","commonSituations":"Hardware or disk failure corrupting an SSTable; manually copied or truncated SSTable files; files transferred without schema compatibility (e.g. upgrading between incompatible versions); filesystem-level corruption; reading an sstable whose compression metadata is missing or mismatched.","solutions":["Identify the file from the exception path and run `nodetool scrub` (or `sstablesplit`/verify tools) on the table so corrupt data is discarded or repaired","Restore the affected SSTables from a backup or repair the replica via `nodetool repair` so a good copy is streamed from another node","Check dmesg / system logs for disk errors and replace failing hardware before restarting the node","Verify the Cassandra version that wrote the sstable matches the reading version; use upgradesstables after version upgrades"],"exampleFix":"// before: repeatedly restarting node without handling corruption\n// after: detect and scrub the corrupt table\nnodetool scrub -- keyspace table\n# or restore from backup / run: nodetool repair -- keyspace table","handlingStrategy":"try-catch","validationCode":"// before reading, verify sstable components exist and pass checksum validation\n// sstableverify / sstablemetadata can detect corruption up front\nif (!new File(path + '-Data.db').exists()) throw new IllegalStateException('missing sstable');","typeGuard":null,"tryCatchPattern":"try {\n    iter = SSTableIdentityIterator.create(meta, sstable, key, file, deletion);\n} catch (CorruptSSTableException e) {\n    logger.error(\"Corrupt sstable {}: {}\", e.getPath(), e.getCause());\n    // trigger scrub/repair, exclude sstable from reads\n}","preventionTips":["Run regular `nodetool scrub` and `nodetool verify` on cold tables","Monitor disk health (SMART) and replace degrading drives proactively","Always stream/copy sstables with Cassandra-native tools, never raw scp","Keep versions consistent and run upgradesstables after upgrades","Maintain RF>1 with regular repairs so corrupt replicas can be re-replaced"],"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"}