{"record":{"id":"f909699d820d4ec1","repo":"apache/cassandra","slug":"corruptsstableexception-wrapping-deserialization-f","errorCode":null,"errorMessage":"CorruptSSTableException wrapping deserialization failure for ${filename}","messagePattern":"CorruptSSTableException wrapping deserialization failure for (.+?)","errorType":"exception","errorClass":"CorruptSSTableException","httpStatus":null,"severity":"critical","filePath":"src/java/org/apache/cassandra/io/sstable/SSTableCursorReader.java","lineNumber":1441,"sourceCode":"        // raw AssertionError.\n        if (dataReader.getPosition() != unfilteredEnd)\n            corruptSSTable(\"cell desync: cells consumed to \" + dataReader.getPosition()\n                            + \", unfiltered body declared end \" + unfilteredEnd);\n        unfilteredEnd = NO_UNFILTERED_END;\n\n        long preFlagsPosition = dataReader.getPosition();\n        int flags = this.basicUnfilteredFlags = dataReader.readUnsignedByte();\n        readRowExtendedFlags(flags, false, preFlagsPosition);\n        return this.state = CELL_END;\n    }\n\n    private int corruptSSTable(Exception e)\n    {\n        ssTableReader.markSuspect();\n        if (e instanceof CorruptSSTableException)\n            throw (CorruptSSTableException) e;\n\n        throw new CorruptSSTableException(e, ssTableReader.getFilename());\n    }\n\n    protected int corruptSSTable(String message)\n    {\n        return corruptSSTable(new IllegalStateException(message));\n    }\n\n    private int nextStateMidPartition(int basicUnfilteredFlags)\n    {\n        if (UnfilteredSerializer.isEndOfPartition(basicUnfilteredFlags))\n        {\n            return afterPartitionEnd();\n        }\n        else if (UnfilteredSerializer.isRow(basicUnfilteredFlags))\n        {\n            return ROW_START;\n        }\n        else","sourceCodeStart":1423,"sourceCodeEnd":1459,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/io/sstable/SSTableCursorReader.java#L1423-L1459","documentation":"When SSTableCursorReader hits a deserialization/IO failure, corruptSSTable(Exception) marks the sstable reader suspect (blacklisting it for reads), rethrows CorruptSSTableException as-is, or wraps any other exception in a new CorruptSSTableException carrying the sstable filename. This is the corruption funnel so callers always see a uniform corrupt-sstable signal.","triggerScenarios":"Any IOException, negative clustering length, bad end-of-partition marker, or bad clustering header raised during cursor iteration is caught and passed to corruptSSTable(e); corruptSSTable(String) wraps IllegalStateExceptions with a message.","commonSituations":"Reading on-disk-corrupt sstables; schema mismatches during reads; truncated data files; compaction or read-path failures surfaced as CorruptSSTableException.","solutions":["Inspect getCause() to find the root failure and affected file.","Run nodetool verify on the named sstable to confirm corruption.","Run nodetool scrub / sstablescrub on the keyspace/table; the file is already marked suspect so reads avoid it.","Restore from backup and run nodetool repair to restore full replicas.","If the cause is schema mismatch rather than bad bytes, fix schema agreement instead of scrubbing."],"exampleFix":"// before\ncatch (Exception e) {\n    throw new RuntimeException(\"read failed\", e); // loses corruption semantics\n}\n// after\ncatch (Exception e) {\n    ssTableReader.markSuspect();\n    throw (e instanceof CorruptSSTableException)\n        ? (CorruptSSTableException) e\n        : new CorruptSSTableException(e, ssTableReader.getFilename());\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    while (cursor.hasNext()) { cursor.next(); }\n} catch (CorruptSSTableException e) {\n    logger.warn(\"SSTable corrupt: {}\", e.getFilename());\n    // schedule scrub/repair; reads avoid the suspect sstable automatically\n}","preventionTips":["Always preserve the cause chain (getCause()) when logging CorruptSSTableException.","Run nodetool scrub promptly for any file reported corrupt.","Maintain replication factor and run repair so corrupt local files are recoverable.","Monitor logs for markSuspect events as an early corruption signal."],"tags":["sstable","corruption","error-handling"],"backgroundTag":"checksum-mismatch","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"}