apache/cassandra · critical · CorruptSSTableException

CorruptSSTableException

Error message

CorruptSSTableException

What it means

resetAndTruncate() catches CorruptBlockException (including an EOFException while reading the chunk, wrapped as a CorruptBlockException) and rethrows it as CorruptSSTableException for the file. This signals that the compressed SSTable being truncated/rewound is unreadable at the requested offset and the write session cannot safely continue.

Solutions

  1. Let the standard failure handling move the broken SSTable aside; then run nodetool scrub to repair or discard it
  2. Restore the file from a snapshot/backup or repair the range from replicas (nodetool repair)
  3. Investigate the cause of the partial write (crash logs, dmesg for I/O errors) and ensure fsync/power-loss protections (UPS, write barriers)
  4. After recovery, confirm table integrity with nodetool verify

Example fix

// before
// unclean shutdown -> EOF reading chunk on truncate -> CorruptSSTableException
// after
nodetool scrub ks tbl
nodetool verify ks tbl
nodetool repair ks tbl
Defensive patterns

Strategy: fallback

Validate before calling

nodetool verify ks tbl
# confirm SSTables are complete and readable after any unclean shutdown

Try / catch

try {
    writer.resetAndTruncate(pos);
} catch (CorruptSSTableException e) {
    // fallback: abandon in-flight write; remove/rename the partial file and rebuild from replicas
    recovery.discardAndRebuild(e.getPath());
}

Prevention

When it happens

Trigger: Truncation point falls in a chunk that is incomplete (EOF while reading chunk or CRC bytes) or fails validation, e.g. a crash mid-flush left a partial last chunk and the writer later attempts to reset and truncate through it.

Common situations: Recovery after unclean shutdown (power loss, OOM kill) leaving truncated compressed SSTables; compaction retries over partially written files; disks returning short reads.

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/bbd3244f3923b2d3. Report an issue: GitHub.

Appendix: source

Thrown at src/java/org/apache/cassandra/io/compress/CompressedSequentialWriter.java:354

            }
            catch (IOException e)
            {
                throw new CorruptBlockException(getPath(), chunkOffset, chunkSize, e);
            }

            CRC32 checksum = new CRC32();
            compressed.rewind();
            checksum.update(compressed);

            crcCheckBuffer.clear();
            fchannel.read(crcCheckBuffer);
            crcCheckBuffer.flip();
            if (crcCheckBuffer.getInt() != (int) checksum.getValue())
                throw new CorruptBlockException(getPath(), chunkOffset, chunkSize);
        }
        catch (CorruptBlockException e)
        {
            throw new CorruptSSTableException(e, getPath());
        }
        catch (EOFException e)
        {
            throw new CorruptSSTableException(new CorruptBlockException(getPath(), chunkOffset, chunkSize), getPath());
        }
        catch (IOException e)
        {
            throw new FSReadError(e, getPath());
        }

        // Mark as dirty so we can guarantee the newly buffered bytes won't be lost on a rebuffer
        buffer.position(realMark.validBufferBytes);

        bufferOffset = truncateTarget - buffer.position();
        chunkCount = realMark.nextChunkIndex - 1;

        // truncate data and index file
        truncate(chunkOffset, bufferOffset);

View on GitHub (pinned to 88fd0f6a0e)