{"record":{"id":"16d31af21f60621d","repo":"apache/cassandra","slug":"error-reading-index-file","errorCode":null,"errorMessage":"Error reading index file","messagePattern":"Error reading index file","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/java/org/apache/cassandra/io/sstable/format/big/BigTableScrubber.java","lineNumber":233,"sourceCode":"        }\n    }\n\n    private void updateIndexKey()\n    {\n        currentIndexKey = nextIndexKey;\n        currentPartitionPositionFromIndex = nextPartitionPositionFromIndex;\n        try\n        {\n            nextIndexKey = !indexAvailable() ? null : ByteBufferUtil.readWithShortLength(indexFile);\n\n            nextPartitionPositionFromIndex = !indexAvailable()\n                                             ? dataFile.length()\n                                             : rowIndexEntrySerializer.deserializePositionAndSkip(indexFile);\n        }\n        catch (Throwable th)\n        {\n            JVMStabilityInspector.inspectThrowable(th);\n            outputHandler.warn(th, \"Error reading index file\");\n            nextIndexKey = null;\n            nextPartitionPositionFromIndex = dataFile.length();\n        }\n    }\n\n    private boolean indexAvailable()\n    {\n        return indexFile != null && !indexFile.isEOF();\n    }\n\n    private boolean seekToNextPartition()\n    {\n        while (nextPartitionPositionFromIndex < dataFile.length())\n        {\n            try\n            {\n                dataFile.seek(nextPartitionPositionFromIndex);\n                return true;","sourceCodeStart":215,"sourceCodeEnd":251,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/io/sstable/format/big/BigTableScrubber.java#L215-L251","documentation":"While advancing the scrubber's index cursor (updateIndexKey), reading the next key/position from the -Index.db failed with a non-fatal Throwable. The scrubber logs the error, nulls the next index key, and treats the end-of-index as the data file length, continuing the scrub without index guidance.","triggerScenarios":"updateIndexKey (called from scrubInternal and seekToNextPartition) catches a Throwable while calling rowIndexEntrySerializer.deserializePositionAndSkip(indexFile) — corrupt or truncated index file, or an undeserializable index entry.","commonSituations":"Truncated -Index.db after a crash, bit-rot in index blocks, index written by a format-version-incompatible writer, or a corrupt promoted index entry inside a row index.","solutions":["Scrub continues without index; afterwards run `nodetool repair` to re-sync data","Replace the sstable from a healthy replica (repair/rebuild) rather than scrubbing degraded","Run `nodetool verify` to confirm the extent of index corruption","Check for disk errors in system logs and address hardware issues first"],"exampleFix":"// before: index unreadable, scrub degrades\noutputHandler.warn(th, \"Error reading index file\");\n// after: restore the index component before scrub\nFiles.copy(snapshotIndex, sstable.descriptor.fileFor(Components.PRIMARY_INDEX), REPLACE_EXISTING);","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try (RandomAccessReader idx = RandomAccessReader.open(indexFile)) {\n    rowIndexEntrySerializer.deserializePositionAndSkip(idx);\n} catch (IOException e) {\n    logger.warn(\"Index file unreadable; scrub will proceed without index\", e);\n}","preventionTips":["Validate index files with `nodetool verify` before scrubbing","Restore Data+Index pairs from the same snapshot","Address disk errors promptly; index reads fail on bad sectors","Keep the Cassandra version consistent with the sstable format version"],"tags":["cassandra","sstable","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"}