{"record":{"id":"cae30f3e44293d69","repo":"apache/cassandra","slug":"last-partition-does-not-match-index","errorCode":null,"errorMessage":"Last partition does not match index","messagePattern":"Last partition does not match index","errorType":"exception","errorClass":"CorruptSSTableException","httpStatus":null,"severity":"critical","filePath":"src/java/org/apache/cassandra/io/sstable/format/big/BigTableVerifier.java","lineNumber":173,"sourceCode":"                        Unfiltered unfiltered = UnfilteredSerializer.serializer.deserialize(dataFile,\n                                                                                            sstable.header,\n                                                                                            deserializationHelper,\n                                                                                            BTreeRow.sortedBuilder());\n                        if (!Objects.equals(indexInfo.firstName, unfiltered.clustering()))\n                            throw new CorruptSSTableException(new IOException(\"Unfiltered clustering in index does not match data:{info=\" + indexInfo.toString(sstable.metadata()) + \", row:\" + unfiltered.clustering().toString(sstable.metadata()) + \"}\"), it.toString());\n\n                        if (comparator.compare(indexInfo.firstName, indexInfo.lastName) > 0)\n                            throw new CorruptSSTableException(new IOException(\"First name is > Last name:{info=\" + indexInfo.toString(sstable.metadata()) + \"}\"), it.toString());\n\n                    }\n                }\n            }\n            // The verifier checks that the partition key/position in the index and data match, here we waant to verify\n            // the entries clustering keys match.\n            while (it.advance()); // no-op, just check if index is readable\n\n            if (!Objects.equals(key, sstable.getLast().getKey()))\n                throw new CorruptSSTableException(new IOException(\"Last partition does not match index\"), it.toString());\n        }\n        if (options.extendedVerification)\n            dataFile.reset();\n    }\n\n    private void logDuplicates(DecoratedKey key, Row first, int duplicateRows, long minTimestamp, long maxTimestamp)\n    {\n        String keyString = sstable.metadata().partitionKeyType.getString(key.getKey());\n        long firstMaxTs = Long.MIN_VALUE;\n        long firstMinTs = Long.MAX_VALUE;\n        for (Cell cell : first.cells())\n        {\n            firstMaxTs = Math.max(firstMaxTs, cell.timestamp());\n            firstMinTs = Math.min(firstMinTs, cell.timestamp());\n        }\n        outputHandler.output(\"%d duplicate rows found for [%s %s] in %s.%s (%s), timestamps: [first row (%s, %s)], [duplicates (%s, %s, eq:%b)]\",\n                             duplicateRows,\n                             keyString, first.clustering().toString(sstable.metadata()),","sourceCodeStart":155,"sourceCodeEnd":191,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/io/sstable/format/big/BigTableVerifier.java#L155-L191","documentation":"Thrown at the end of index verification when the last key read from the data file does not match the last partition key recorded in the index (sstable.getLast()). The SSTable's data file is missing partitions present in the index or contains extra/reordered data.","triggerScenarios":"`nodetool verify` on an SSTable whose Data.db final partition differs from the Summary/Index last key, e.g. truncated Data.db or stale index components.","commonSituations":"Crash during compaction/flush; truncated files from disk-full; copying partial SSTable sets; version mismatch when moving files.","solutions":["Scrub the SSTable or delete and repair/rebuild from replicas","Restore from a verified backup snapshot","Run verify on all SSTables to scope the corruption before replacing hardware"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { verifier.verify(); }\ncatch (CorruptSSTableException e) { logger.error(\"Last partition mismatch in {}\", e.getFilename()); scrubOrRestore(descriptor); }","preventionTips":["Never move partial SSTable file sets between nodes","Snapshot-based backups only","Run nodetool verify after bulk restores","Prevent disk-full conditions during flush/compaction"],"tags":["sstable","corruption","verifier","index"],"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"}