{"record":{"id":"4b8f835eb308e11a","repo":"apache/cassandra","slug":"decompression-failed-4b8f83","errorCode":null,"errorMessage":"Decompression failed","messagePattern":"Decompression failed","errorType":"exception","errorClass":"java.io.IOException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/io/compress/ZstdDictionaryCompressor.java","lineNumber":157,"sourceCode":"    @Override\n    public int uncompress(byte[] input, int inputOffset, int inputLength, byte[] output, int outputOffset) throws IOException\n    {\n        // fallback to non-dict zstd compressor\n        if (dictionary == null)\n        {\n            return super.uncompress(input, inputOffset, inputLength, output, outputOffset);\n        }\n\n        int dsz;\n        try\n        {\n            dsz = (int) Zstd.decompressFastDict(output, outputOffset,\n                                                input, inputOffset, inputLength,\n                                                dictionary.dictionaryForDecompression());\n        }\n        catch (Exception e)\n        {\n            throw new IOException(\"Decompression failed\", e);\n        }\n\n        if (Zstd.isError(dsz))\n            throw new IOException(\"Decompression failed due to \" + Zstd.getErrorName(dsz));\n\n        return dsz;\n    }\n\n    @Override\n    public void uncompress(ByteBuffer input, ByteBuffer output) throws IOException\n    {\n        if (dictionary == null)\n        {\n            super.uncompress(input, output);\n            return;\n        }\n\n        try","sourceCodeStart":139,"sourceCodeEnd":175,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/io/compress/ZstdDictionaryCompressor.java#L139-L175","documentation":"Thrown by ZstdDictionaryCompressor.uncompress when the underlying Zstd JNI decompression call (Zstd.decompressFastDict) throws an exception, e.g. due to corrupted, truncated, or non-Zstd input, or a mismatched/incompatible decompression dictionary. It wraps the original exception as the cause of an IOException so callers of the compression layer can handle it uniformly.","triggerScenarios":"Calling uncompress(byte[], byte[], int) (directly or via decompressedLength) with input bytes that were not produced by this compressor, are truncated, or were compressed with a different (or no) dictionary, causing the Zstd JNI call to throw.","commonSituations":"Reading an sstable compressed with Zstd+dictionary after the dictionary was rotated or lost; manually assembling compressed chunks; version mismatch between writer and reader compression parameters.","solutions":["Check the cause exception via getCause() to see the exact Zstd failure","Verify the input chunk belongs to the file whose compression metadata (dictionary) is being used","Confirm the dictionary used at read time matches the one recorded in the sstable compression parameters","Re-read or re-fetch the corrupted data from a replica/backup"],"exampleFix":"// before\nbyte[] out = new byte[1024];\ncompressor.uncompress(chunk, out, 0);\n// after\ntry {\n    compressor.uncompress(chunk, out, 0);\n} catch (IOException e) {\n    logger.error(\"Zstd decompression failed for chunk, cause: {}\", e.getCause());\n    throw new CorruptSSTableException(e, file.getPath());\n}","handlingStrategy":"try-catch","validationCode":"if (input == null || inputLength <= 0) throw new IllegalArgumentException(\"invalid compressed input\");","typeGuard":"boolean looksCompressed(byte[] in) { return in != null && in.length >= 4; }","tryCatchPattern":"try { compressor.uncompress(input, output, outputOffset); } catch (IOException e) { throw new CorruptSSTableException(e.getCause(), chunkPath); }","preventionTips":["Always use the dictionary from the same sstable compression parameters the data was written with","Validate chunk lengths against file metadata before decompressing","Handle CorruptSSTableException by re-fetching the data from a replica","Log e.getCause() to capture the underlying Zstd error"],"tags":["io","zstd","decompression","corrupt-data"],"backgroundTag":"file-read-failed","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"}