apache/cassandra · critical · CorruptSSTableException

Last partition does not match index

Error message

Last partition does not match index

What it means

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.

Source

Thrown at src/java/org/apache/cassandra/io/sstable/format/big/BigTableVerifier.java:173

                        Unfiltered unfiltered = UnfilteredSerializer.serializer.deserialize(dataFile,
                                                                                            sstable.header,
                                                                                            deserializationHelper,
                                                                                            BTreeRow.sortedBuilder());
                        if (!Objects.equals(indexInfo.firstName, unfiltered.clustering()))
                            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());

                        if (comparator.compare(indexInfo.firstName, indexInfo.lastName) > 0)
                            throw new CorruptSSTableException(new IOException("First name is > Last name:{info=" + indexInfo.toString(sstable.metadata()) + "}"), it.toString());

                    }
                }
            }
            // The verifier checks that the partition key/position in the index and data match, here we waant to verify
            // the entries clustering keys match.
            while (it.advance()); // no-op, just check if index is readable

            if (!Objects.equals(key, sstable.getLast().getKey()))
                throw new CorruptSSTableException(new IOException("Last partition does not match index"), it.toString());
        }
        if (options.extendedVerification)
            dataFile.reset();
    }

    private void logDuplicates(DecoratedKey key, Row first, int duplicateRows, long minTimestamp, long maxTimestamp)
    {
        String keyString = sstable.metadata().partitionKeyType.getString(key.getKey());
        long firstMaxTs = Long.MIN_VALUE;
        long firstMinTs = Long.MAX_VALUE;
        for (Cell cell : first.cells())
        {
            firstMaxTs = Math.max(firstMaxTs, cell.timestamp());
            firstMinTs = Math.min(firstMinTs, cell.timestamp());
        }
        outputHandler.output("%d duplicate rows found for [%s %s] in %s.%s (%s), timestamps: [first row (%s, %s)], [duplicates (%s, %s, eq:%b)]",
                             duplicateRows,
                             keyString, first.clustering().toString(sstable.metadata()),

View on GitHub (pinned to 88fd0f6a0e)

Solutions

  1. Scrub the SSTable or delete and repair/rebuild from replicas
  2. Restore from a verified backup snapshot
  3. Run verify on all SSTables to scope the corruption before replacing hardware
Defensive patterns

Strategy: validation

Try / catch

try { verifier.verify(); }
catch (CorruptSSTableException e) { logger.error("Last partition mismatch in {}", e.getFilename()); scrubOrRestore(descriptor); }

Prevention

When it happens

Trigger: `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.

Common situations: Crash during compaction/flush; truncated files from disk-full; copying partial SSTable sets; version mismatch when moving files.

Understand the failure class

Background: Checksum mismatch errors: "checksum verification failed", "digest mismatch", "expected vs actual checksum" — what they mean and how to fix them — this error's family across 41 libraries.

Related errors


AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10). Data as JSON: /api/errors/cae30f3e44293d69. Report an issue: GitHub.