{"record":{"id":"60f6d603b550ab53","repo":"apache/cassandra","slug":"compression-dictionary-checksum-does-not-match-ex","errorCode":null,"errorMessage":"Compression dictionary checksum does not match. Expected: %s; actual: %s","messagePattern":"Compression dictionary checksum does not match\\. Expected: (.+?); actual: (.+?)","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/db/compression/CompressionDictionary.java","lineNumber":252,"sourceCode":"        long id = input.readLong();\n        DictId dictId = new DictId(kind, id);\n\n        if (manager != null)\n        {\n            CompressionDictionary dictionary = manager.get(dictId);\n            if (dictionary != null)\n            {\n                return dictionary;\n            }\n        }\n\n        int length = input.readInt();\n        byte[] dict = new byte[length];\n        input.readFully(dict);\n        int checksum = input.readInt();\n        int calculatedChecksum = calculateChecksum((byte) kindOrdinal, id, dict);\n        if (checksum != calculatedChecksum)\n            throw new IOException(\"Compression dictionary checksum does not match. \" +\n                                  \"Expected: \" + checksum + \"; actual: \" + calculatedChecksum);\n\n        CompressionDictionary dictionary = kind.createDictionary(dictId, dict, checksum);\n\n        // update the dictionary manager if it exists\n        if (manager != null)\n        {\n            manager.add(dictionary);\n        }\n\n        return dictionary;\n    }\n\n    static LightweightCompressionDictionary createFromRowLightweight(UntypedResultSet.Row row)\n    {\n        String kindStr = row.getString(\"kind\");\n        long dictId = row.getLong(\"dict_id\");\n        int checksum = row.getInt(\"dict_checksum\");","sourceCodeStart":234,"sourceCodeEnd":270,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/db/compression/CompressionDictionary.java#L234-L270","documentation":"After reading a serialized compression dictionary's bytes, deserialize recomputes a checksum over (kindOrdinal, id, bytes) and compares it to the stored checksum. A mismatch means the dictionary payload was corrupted in storage or transit, so an IOException is thrown to prevent using broken dictionary data.","triggerScenarios":"Reading a compression dictionary whose stored checksum differs from calculateChecksum(kindOrdinal, id, dict) — e.g. bit rot, truncated/partial write, or bytes altered between write and read.","commonSituations":"Failing disk sectors, interrupted file copies of zstd dictionaries, corruption during backup/restore of dictionary files or the system table.","solutions":["Re-transfer or re-provision the dictionary file from a healthy source.","Delete the corrupted dictionary and regenerate it (re-run dictionary training) so the compressor creates a fresh one.","Check hardware/filesystem health (SMART, fsck) if corruption recurs.","Restore from backup if the dictionary cannot be regenerated."],"exampleFix":"null","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    dict = CompressionDictionary.deserialize(input, manager);\n} catch (IOException e) {\n    if (e.getMessage().contains(\"checksum does not match\")) { quarantineCorruptFile(); regenerateDictionary(); }\n    else throw e;\n}","preventionTips":["Use ECC/storage monitoring to catch bit rot early","Validate checksums after transferring dictionary files","Restore dictionaries only from verified backups"],"tags":["cassandra","compression","corruption","checksum"],"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"}