apache/cassandra · critical · CorruptSSTableException
First partition does not match index
Error message
First partition does not match index
What it means
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.
Source
Thrown at src/java/org/apache/cassandra/io/sstable/format/big/BigTableVerifier.java:129
protected void deserializeIndex(SSTableReader sstable) throws IOException
{
DeserializationHelper deserializationHelper = new DeserializationHelper(sstable.metadata(),
sstable.descriptor.version.correspondingMessagingVersion(),
DeserializationHelper.Flag.LOCAL);
ClusteringComparator comparator = sstable.metadata().comparator;
try (BigTableKeyReader it = (BigTableKeyReader)sstable.keyReader(true))
{
if (it.isExhausted())
return;
ByteBuffer key;
boolean isFirst = true;
do
{
key = it.key();
if (outputHandler.isDebugEnabled()) outputHandler.debug("Key %s", sstable.metadata().partitionKeyType.getString(key));
if (isFirst && !Objects.equals(key, sstable.getFirst().getKey()))
throw new CorruptSSTableException(new IOException("First partition does not match index"), it.toString());
else
isFirst = false;
RowIndexEntry rowIndexEntry = it.rowIndexEntry();
if (outputHandler.isDebugEnabled()) outputHandler.debug("rowIndexEntry %s", rowIndexEntry.toString());
long partitionBase = it.dataPosition();
int blockCount = rowIndexEntry.blockCount();
if (options.extendedVerification && blockCount > 0)
{
long expectedNextOffset = 0;
RowIndexEntry.IndexInfoRetriever indexInfoRetriever = rowIndexEntry.openWithIndex(it.indexFile());
for (int blockIndex = 0; blockIndex < blockCount; blockIndex++)
{
IndexInfo indexInfo = indexInfoRetriever.columnsIndex(blockIndex);
if (outputHandler.isDebugEnabled()) outputHandler.debug("indexInfo %s", indexInfo.toString(sstable.metadata()));
long dataFileOffset = partitionBase + indexInfo.offset;
if (expectedNextOffset != 0)View on GitHub (pinned to 88fd0f6a0e)
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
Defensive patterns
Strategy: validation
Validate before calling
// Periodically validate SSTables // nodetool verify <keyspace> <table> // or in code: new BigTableVerifier(cfs, sstable, options).verify();
Try / catch
try { verifier.verify(); }
catch (CorruptSSTableException e) { logger.error("SSTable corrupt: {}", e.getFilename()); markForScrubOrRepair(descriptor); } Prevention
- 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
When it happens
Trigger: 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.
Common situations: Partially written or truncated Data.db from a crash; manual edits to SSTable files; corrupted disk; mixing SSTable files from different snapshots/versions.
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
- Last partition does not match index
- Failed to read partition index
- The requested position exceeds the index length
- Key from data file (%s) does not match key from index file (
- Row entry indexInfo offset + width should match next block o
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/14c81846fa1b42f1.
Report an issue: GitHub.