{"record":{"id":"14c81846fa1b42f1","repo":"apache/cassandra","slug":"first-partition-does-not-match-index","errorCode":null,"errorMessage":"First partition does not match index","messagePattern":"First 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":129,"sourceCode":"    protected void deserializeIndex(SSTableReader sstable) throws IOException\n    {\n        DeserializationHelper deserializationHelper = new DeserializationHelper(sstable.metadata(),\n                                                                                sstable.descriptor.version.correspondingMessagingVersion(),\n                                                                                DeserializationHelper.Flag.LOCAL);\n        ClusteringComparator comparator = sstable.metadata().comparator;\n        try (BigTableKeyReader it = (BigTableKeyReader)sstable.keyReader(true))\n        {\n            if (it.isExhausted())\n                return;\n            ByteBuffer key;\n            boolean isFirst = true;\n            do\n            {\n                key = it.key();\n                if (outputHandler.isDebugEnabled()) outputHandler.debug(\"Key %s\", sstable.metadata().partitionKeyType.getString(key));\n\n                if (isFirst && !Objects.equals(key, sstable.getFirst().getKey()))\n                    throw new CorruptSSTableException(new IOException(\"First partition does not match index\"), it.toString());\n                else\n                    isFirst = false;\n                RowIndexEntry rowIndexEntry = it.rowIndexEntry();\n                if (outputHandler.isDebugEnabled()) outputHandler.debug(\"rowIndexEntry %s\", rowIndexEntry.toString());\n\n                long partitionBase = it.dataPosition();\n                int blockCount = rowIndexEntry.blockCount();\n                if (options.extendedVerification && blockCount > 0)\n                {\n                    long expectedNextOffset = 0;\n                    RowIndexEntry.IndexInfoRetriever indexInfoRetriever = rowIndexEntry.openWithIndex(it.indexFile());\n                    for (int blockIndex = 0; blockIndex < blockCount; blockIndex++)\n                    {\n                        IndexInfo indexInfo = indexInfoRetriever.columnsIndex(blockIndex);\n                        if (outputHandler.isDebugEnabled()) outputHandler.debug(\"indexInfo %s\", indexInfo.toString(sstable.metadata()));\n\n                        long dataFileOffset = partitionBase + indexInfo.offset;\n                        if (expectedNextOffset != 0)","sourceCodeStart":111,"sourceCodeEnd":147,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/io/sstable/format/big/BigTableVerifier.java#L111-L147","documentation":"Thrown by the SSTable verifier when the first key read from the data file does not equal the first partition key recorded in the index (sstable.getFirst()). It indicates the data and index components disagree about the first partition, i.e. the SSTable is corrupt.","triggerScenarios":"Running `nodetool verify` (SSTableVerifier.verify with extended options) on an SSTable whose Data.db first partition key differs from the key stored in the Summary/Index components.","commonSituations":"Partially written or truncated Data.db from a crash; manual edits to SSTable files; corrupted disk; mixing SSTable files from different snapshots/versions.","solutions":["Scrub the SSTable (`nodetool scrub`) to rewrite consistent components, or delete it and repair (`nodetool repair` / rebuild from replicas)","Restore the SSTable from a verified backup/snapshot","Check storage health and avoid editing/copying live SSTables"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Periodically validate SSTables\n// nodetool verify <keyspace> <table>\n// or in code: new BigTableVerifier(cfs, sstable, options).verify();","typeGuard":null,"tryCatchPattern":"try { verifier.verify(); }\ncatch (CorruptSSTableException e) { logger.error(\"SSTable corrupt: {}\", e.getFilename()); markForScrubOrRepair(descriptor); }","preventionTips":["Copy SSTables only from snapshots, never while live","Run nodetool verify after restores or manual file moves","Keep clean backups/snapshots of SSTables","Avoid unclean shutdowns; use UPS/suicide timers to fail fast"],"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"}