{"record":{"id":"2e04526aefa54702","repo":"apache/cassandra","slug":"corrupted-file-integrity-check-s-failed-for-s","errorCode":null,"errorMessage":"Corrupted file: integrity check (%s) failed for %s: %d != %d","messagePattern":"Corrupted file: integrity check \\((.+?)\\) failed for (.+?): (.+?) != (.+?)","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/io/util/DataIntegrityMetadata.java","lineNumber":67,"sourceCode":"\n        public void seek(long offset)\n        {\n            long start = chunkStart(offset);\n            reader.seek(((start / chunkSize) * 4L) + 4); // 8 byte checksum per chunk + 4 byte header/chunkLength\n        }\n\n        public long chunkStart(long offset)\n        {\n            long startChunk = offset / chunkSize;\n            return startChunk * chunkSize;\n        }\n\n        public void validate(byte[] bytes, int start, int end) throws IOException\n        {\n            int calculatedValue = (int) checksumType.of(bytes, start, end);\n            int storedValue = reader.readInt();\n            if (calculatedValue != storedValue)\n                throw new IOException(String.format(\"Corrupted file: integrity check (%s) failed for %s: %d != %d\", checksumType.name(), reader.getPath(), storedValue, calculatedValue));\n        }\n\n        /**\n         * validates the checksum with the bytes from the specified buffer.\n         *\n         * Upon return, the buffer's position will\n         * be updated to its limit; its limit will not have been changed.\n         */\n        public void validate(ByteBuffer buffer) throws IOException\n        {\n            int calculatedValue = (int) checksumType.of(buffer);\n            int storedValue = reader.readInt();\n            if (calculatedValue != storedValue)\n                throw new IOException(String.format(\"Corrupted file: integrity check (%s) failed for %s: %d != %d\", checksumType.name(), reader.getPath(), storedValue, calculatedValue));\n        }\n\n        public void close()\n        {","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/io/util/DataIntegrityMetadata.java#L49-L85","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nvalidator.validate(bytes, 0, bytes.length);\n// after\ntry {\n    validator.validate(bytes, 0, bytes.length);\n} catch (IOException e) {\n    logger.error(\"Integrity check failed for {}\", reader.getPath(), e);\n    markSSTableCorrupted(sstable);\n    throw e;\n}\n","handlingStrategy":"validation","validationCode":"// ensure data and checksum sidecar exist and belong to the same generation before validating\nif (!checksumFileExists(dataFile)) throw new IOException(\"No checksum sidecar for \" + dataFile);","typeGuard":null,"tryCatchPattern":"try { validator.validate(bytes, start, end); }\ncatch (IOException e) { quarantine(sstable); throw e; }","preventionTips":["Copy SSTable data and checksum components together","Run nodetool verify/scrub regularly","Monitor storage for bit rot","Never edit data files in place"],"tags":["io","checksum","corruption","sstable"],"backgroundTag":"checksum-mismatch","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}