apache/cassandra · error · IOException
Corrupted file: integrity check (%s) failed for %s: %d != %d
Error message
Corrupted file: integrity check (%s) failed for %s: %d != %d
What it means
FileSegmentInputStream/ChecksummedDataInput's FileMetadataValidator (bytes variant) compares a stored checksum read from the checksum file against a CRC/Adler32 computed over the supplied byte range. On mismatch it throws this IOException, indicating the data bytes are corrupt relative to the sidecar checksum file.
Source
Thrown at src/java/org/apache/cassandra/io/util/DataIntegrityMetadata.java:67
public void seek(long offset)
{
long start = chunkStart(offset);
reader.seek(((start / chunkSize) * 4L) + 4); // 8 byte checksum per chunk + 4 byte header/chunkLength
}
public long chunkStart(long offset)
{
long startChunk = offset / chunkSize;
return startChunk * chunkSize;
}
public void validate(byte[] bytes, int start, int end) throws IOException
{
int calculatedValue = (int) checksumType.of(bytes, start, end);
int storedValue = reader.readInt();
if (calculatedValue != storedValue)
throw new IOException(String.format("Corrupted file: integrity check (%s) failed for %s: %d != %d", checksumType.name(), reader.getPath(), storedValue, calculatedValue));
}
/**
* validates the checksum with the bytes from the specified buffer.
*
* Upon return, the buffer's position will
* be updated to its limit; its limit will not have been changed.
*/
public void validate(ByteBuffer buffer) throws IOException
{
int calculatedValue = (int) checksumType.of(buffer);
int storedValue = reader.readInt();
if (calculatedValue != storedValue)
throw new IOException(String.format("Corrupted file: integrity check (%s) failed for %s: %d != %d", checksumType.name(), reader.getPath(), storedValue, calculatedValue));
}
public void close()
{View on GitHub (pinned to 88fd0f6a0e)
Solutions
- Run scrub/rebuild on the affected SSTable (nodetool scrub) or restore the component from a replica/backup.
- Ensure the data file and its checksum sidecar belong to the same SSTable generation — re-copy the whole SSTable set together.
- Check disk health (SMART/fsck); replace failing hardware.
- If corruption is reproducible on read, stop using the disk and rebuild the node.
Example fix
// before
validator.validate(bytes, 0, bytes.length);
// after
try {
validator.validate(bytes, 0, bytes.length);
} catch (IOException e) {
logger.error("Integrity check failed for {}", reader.getPath(), e);
markSSTableCorrupted(sstable);
throw e;
}
Defensive patterns
Strategy: validation
Validate before calling
// ensure data and checksum sidecar exist and belong to the same generation before validating
if (!checksumFileExists(dataFile)) throw new IOException("No checksum sidecar for " + dataFile); Try / catch
try { validator.validate(bytes, start, end); }
catch (IOException e) { quarantine(sstable); throw e; } Prevention
- Copy SSTable data and checksum components together
- Run nodetool verify/scrub regularly
- Monitor storage for bit rot
- Never edit data files in place
When it happens
Trigger: Calling validate(bytes, start, end) during SSTable component reads when the data component bytes differ from the checksum recorded in the -Checksum.db / digest sidecar file — bit rot, partial write, or mismatched data/checksum file pairs.
Common situations: Bootstrapping/repair reading SSTables whose data file was corrupted on disk; copying SSTable components out of order so data and checksum files come from different generations; failed disk or silent filesystem corruption.
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
- Checksums do not match for
- Corrupt flags value for clustering prefix (isStatic flag set
- Corrupted sstable. Invalid flags found deserializing Deletio
- Failed to import sstable <filename>
- Checksum didn't match (expected: %d, actual: %d)
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/2e04526aefa54702.
Report an issue: GitHub.