{"record":{"id":"cf9c818e7f6e5236","repo":"apache/cassandra","slug":"failed-to-read-partition-index","errorCode":null,"errorMessage":"Failed to read partition index","messagePattern":"Failed to read partition index","errorType":"exception","errorClass":"CorruptSSTableException","httpStatus":null,"severity":"critical","filePath":"src/java/org/apache/cassandra/io/sstable/format/SortedTableVerifier.java","lineNumber":398,"sourceCode":"        {\n            if (outputHandler.isDebugEnabled()) outputHandler.debug(\"Deserializing index for %s\", sstable);\n            deserializeIndex(sstable);\n        }\n        catch (Throwable t)\n        {\n            outputHandler.warn(t);\n            markAndThrow(t);\n        }\n    }\n\n    protected void deserializeIndex(SSTableReader sstable) throws IOException\n    {\n        try (KeyReader it = sstable.keyReader())\n        {\n            ByteBuffer last = it.key();\n            while (it.advance()) last = it.key(); // no-op, just check if index is readable\n            if (!Objects.equals(last, sstable.getLast().getKey()))\n                throw new CorruptSSTableException(new IOException(\"Failed to read partition index\"), it.toString());\n        }\n    }\n\n    @Override\n    public void close()\n    {\n        fileAccessLock.writeLock().lock();\n        try\n        {\n            FileUtils.closeQuietly(dataFile);\n        }\n        finally\n        {\n            fileAccessLock.writeLock().unlock();\n        }\n    }\n\n    /**","sourceCodeStart":380,"sourceCodeEnd":416,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/io/sstable/format/SortedTableVerifier.java#L380-L416","documentation":"During `nodetool verify --check-data` index validation, deserializeIndex walks the entire partition index via KeyReader and confirms the final key equals the SSTable's last decorated key. If the index cannot be read to the end or the last index key doesn't match the expected last key, it throws CorruptSSTableException('Failed to read partition index').","triggerScenarios":"Index file (Summary.db/Index.db) truncated or corrupted so KeyReader.advance() throws or terminates early, or the last indexed key no longer equals sstable.getLast().getKey() — e.g. damaged Index.db, bad summary, tampered files.","commonSituations":"Disk corruption/bitrot, crash during compaction leaving a half-written index, files copied incompletely between nodes, restoring inconsistent backup pieces (data file without matching index).","solutions":["Run `nodetool repair` after removing/scrubbing the affected SSTable so good replicas replace it.","Run `nodetool scrub` to salvage what is readable.","Check the backup/transfer: re-copy all SSTable components of that generation together (Data.db, Index.db, Summary.db, TOC.txt).","Investigate underlying disk health if corruption repeats."],"exampleFix":"// before: verify reports unreadable partition index\nnodetool verify keyspace1 standard1\n// after\nnodetool scrub keyspace1 standard1\nnodetool repair keyspace1","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    verifier.verify();\n} catch (CorruptSSTableException e) {\n    // index unreadable: scrub then repair\n    runScrub(keyspace, table);\n    runRepair(keyspace, table);\n}","preventionTips":["Verify backups by restoring them completely, not partially","Graceful shutdowns / clean compaction completion reduce half-written files","Use checksumming filesystems (ZFS/btrfs) to catch bitrot"],"tags":["sstable","index","corruption","verification"],"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"}