apache/cassandra · error · CorruptSSTableException

Corrupted Index File

Error message

Corrupted Index File %s: read %d but expected %d chunks.

What it means

readChunkOffsets() reads the chunk offset array from the compression index file. If it hits EOF before reading all expected chunkCount offsets, the index file is inconsistent with its own header, so it throws CorruptSSTableException reporting how many chunks were read vs expected. Non-EOF I/O errors become FSReadError.

Solutions

  1. Run nodetool scrub (with --skip-corrupted if needed) to repair or quarantine the SSTable
  2. Restore the CompressionInfo.db from backup or re-stream the SSTable via nodetool repair
  3. Regenerate compression metadata by rewriting the SSTable (upgrade-sstables/alter compression and full rewrite)
  4. Investigate the copy/backup procedure — copy SSTables only after flush/snapshot (nodetool snapshot)

Example fix

// before
cp /var/lib/cassandra/data/ks/t-*/xx-CompressionInfo.db /backup/  // while writers active
// after
nodetool snapshot ks -t pre_backup
cp /var/lib/cassandra/data/ks/t-*/snapshots/pre_backup/* /backup/
Defensive patterns

Strategy: try-catch

Validate before calling

// Confirm index file size matches expected chunk count before open
long expected = 8L * chunkCount;
if (indexFile.length() - HEADER_SIZE < expected)
    throw new IllegalStateException("Index too small: " + indexFile);

Try / catch

try { CompressionMetadata.open(file, len); }
catch (CorruptSSTableException e) { logger.error("Corrupt index {}", file, e); scrubOrRestore(file); }

Prevention

When it happens

Trigger: Opening a compressed SSTable whose -CompressionInfo.db is shorter than expected: partial write during flush, truncated copy, or corruption. open() → readChunkOffsets hits EOFException mid-array.

Common situations: Crash while the compression metadata was being written; rsync/scp of an active SSTable without freezing; disk corruption; manually deleting/truncating metadata 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/ddee0c25eaac92ca. Report an issue: GitHub.

Appendix: source

Thrown at src/java/org/apache/cassandra/io/compress/CompressionMetadata.java:317

        {

            for (i = 0; i < chunkCount; i++)
            {
                offsets.setLong(i * 8L, input.readLong());
            }

            return offsets;
        }
        catch (IOException e)
        {
            if (offsets != null)
                offsets.close();

            if (e instanceof EOFException)
            {
                String msg = String.format("Corrupted Index File %s: read %d but expected %d chunks.",
                                           input.file.path(), i, chunkCount);
                throw new CorruptSSTableException(new IOException(msg, e), input.file);
            }
            throw new FSReadError(e, input.file);
        }
    }

    /**
     * Get a chunk of compressed data (offset, length) corresponding to given position
     *
     * @param position Position in the file.
     * @return pair of chunk offset and length.
     */
    public Chunk chunkFor(long position)
    {
        // position of the chunk
        long idx = 8 * (position / parameters.chunkLength());

        if (idx >= chunkOffsetsSize)
            throw new CorruptSSTableException(new EOFException(), chunksIndexFile);

View on GitHub (pinned to 88fd0f6a0e)