{"record":{"id":"104b2440b49dc4c5","repo":"apache/cassandra","slug":"corruptsstableexception-wrapping-indexoutofboundse","errorCode":null,"errorMessage":"CorruptSSTableException wrapping IndexOutOfBoundsException|VIntOutOfRangeException|AssertionError for ${filename}","messagePattern":"CorruptSSTableException wrapping IndexOutOfBoundsException\\|VIntOutOfRangeException\\|AssertionError for (.+?)","errorType":"exception","errorClass":"CorruptSSTableException","httpStatus":null,"severity":"critical","filePath":"src/java/org/apache/cassandra/io/sstable/SSTableIdentityIterator.java","lineNumber":195,"sourceCode":"    {\n        return partitionLevelDeletion;\n    }\n\n    public Row staticRow()\n    {\n        return staticRow;\n    }\n\n    public boolean hasNext()\n    {\n        try\n        {\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        }","sourceCodeStart":177,"sourceCodeEnd":213,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/io/sstable/SSTableIdentityIterator.java#L177-L213","documentation":"SSTableIdentityIterator.hasNext() guards against in-band corruption signs: IndexOutOfBoundsException, VIntOutOfRangeException, and AssertionError thrown while parsing rows are converted to CorruptSSTableException with the sstable filename after marking the sstable suspect. These exception types indicate the byte stream does not match the expected row layout rather than a low-level I/O failure.","triggerScenarios":"Calling hasNext() on a partially-read SSTableIdentityIterator when the underlying SSTableSimpleIterator misparses data: an out-of-bounds read from a truncated cell, an oversized/invalid VInt encoded length, or an assertion about row structure failing.","commonSituations":"SSTables written by an incompatible Cassandra version; bit-flip corruption on disk; files truncated mid-row by a crash or bad copy; manually edited or patched sstable bytes; corrupted compressed chunks.","solutions":["Scrub the affected table with `nodetool scrub` so the corrupt partition is dropped or rewritten","Run `nodetool repair` to repopulate the lost data from healthy replicas, or restore from backup","Check whether the sstable was written by a different Cassandra version and run `nodetool upgradesstables` if needed","Verify disk health and re-checksum copied sstable files; replace failing hardware"],"exampleFix":"// before: retrying reads of the same corrupt sstable\n// after: scrub and repair\nnodetool scrub -- keyspace table\nnodetool repair -- keyspace table","handlingStrategy":"try-catch","validationCode":"// detect likely corruption before full reads\n// run sstablemetadata / nodetool verify on the sstable ahead of application reads\nboolean verified = verifySstable(filename); // invoke sstableverify out-of-band","typeGuard":null,"tryCatchPattern":"try {\n    while (iter.hasNext()) { consume(iter.next()); }\n} catch (CorruptSSTableException e) {\n    logger.error(\"Corrupt sstable {} during iteration\", e.getPath(), e);\n    // retry read against a healthy replica; queue table for scrub\n}","preventionTips":["Keep cluster versions aligned; upgradesstables after upgrades","Use error-correcting storage (ECC RAM, healthy disks)","Avoid manual copying of sstable data files","Run periodic repairs to detect and fix divergent replicas","Alert on CorruptSSTableException in logs"],"tags":["sstable","corruption","parsing","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-17T15:17:12.973Z"}