{"record":{"id":"e75e0ccac12dfb0a","repo":"apache/cassandra","slug":"detected-corruption-in-the-index-file-cannot-ope","errorCode":null,"errorMessage":"Detected corruption in the index file - cannot open index iterator","messagePattern":"Detected corruption in the index file - cannot open index iterator","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/java/org/apache/cassandra/io/sstable/format/bti/BtiTableScrubber.java","lineNumber":72,"sourceCode":"\n        boolean hasIndexFile = sstable.getComponents().contains(Components.PARTITION_INDEX);\n        this.isIndex = cfs.isIndex();\n        this.partitionKeyType = cfs.metadata.get().partitionKeyType;\n        if (!hasIndexFile)\n        {\n            // if there's any corruption in the -Data.db then partitions can't be skipped over. but it's worth a shot.\n            outputHandler.warn(\"Missing index component\");\n        }\n\n        try\n        {\n            this.indexIterator = hasIndexFile\n                                 ? openIndexIterator()\n                                 : null;\n        }\n        catch (RuntimeException ex)\n        {\n            outputHandler.warn(\"Detected corruption in the index file - cannot open index iterator\", ex);\n        }\n    }\n\n    private ScrubPartitionIterator openIndexIterator()\n    {\n        try\n        {\n            return sstable.scrubPartitionsIterator();\n        }\n        catch (Throwable t)\n        {\n            outputHandler.warn(t, \"Index is unreadable, scrubbing will continue without index.\");\n        }\n        return null;\n    }\n\n    @Override\n    protected UnfilteredRowIterator withValidation(UnfilteredRowIterator iter, String filename)","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/io/sstable/format/bti/BtiTableScrubber.java#L54-L90","documentation":"Opening the BTI partition-index iterator threw a RuntimeException, indicating the index file is corrupt or cannot be parsed. The scrubber warns and continues scrubbing without the index, degrading its ability to skip corrupt partitions.","triggerScenarios":"BtiTableScrubber constructor: openIndexIterator() throws RuntimeException (e.g. from BTI index file parsing/validation) — corrupt -PartitionIndex.db, invalid metadata/footer, or a truncated file.","commonSituations":"Bit-rot or truncated index after unclean shutdown, sstable corrupted in transit during restore, incompatible index file version after a version downgrade.","solutions":["Replace the sstable from a healthy replica via repair/rebuild","Restore the -PartitionIndex.db from a snapshot","Run scrub accepting degraded (index-less) behavior, then repair","Check filesystem/disk health; run fsck/SMART checks on the data directory"],"exampleFix":"// before: corrupt BTI index degrades the scrub\ncatch (RuntimeException ex) { outputHandler.warn(\"Detected corruption in the index file - cannot open index iterator\", ex); }\n// after: detect corruption before scrub\nnodetool verify keyspace table; // replaces sstable if index is corrupt\nnodetool scrub keyspace table;","handlingStrategy":"try-catch","validationCode":"try {\n    sstable.scrubPartitionsIterator(); // probe open\n} catch (RuntimeException e) {\n    logger.warn(\"BTI index corrupt; replace sstable before scrub\", e);\n}","typeGuard":null,"tryCatchPattern":"try {\n    iterator = sstable.scrubPartitionsIterator();\n} catch (RuntimeException ex) {\n    logger.warn(\"Index corrupt, scrubbing without index\", ex);\n    iterator = null;\n}","preventionTips":["Run `nodetool verify` (validates BTI indexes) before scrub","Restore sstables with checksum-verified transfer tools","Avoid unclean shutdowns; use graceful drain/stop","Keep one Cassandra version per sstable generation to avoid format mismatch"],"tags":["cassandra","bti","index","corruption"],"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"}