{"record":{"id":"c45dd34b6a378dca","repo":"apache/cassandra","slug":"decompression-failed-due-to-c45dd3","errorCode":null,"errorMessage":"Decompression failed due to ","messagePattern":"Decompression failed due to ","errorType":"exception","errorClass":"java.io.IOException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/io/compress/ZstdDictionaryCompressor.java","lineNumber":161,"sourceCode":"        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\n        {\n            // Zstd compressors expect only direct bytebuffer. See ZstdCompressorBase.preferredBufferType and supports\n            int decompressedSize = (int) Zstd.decompressDirectByteBufferFastDict(output, output.position(), output.limit() - output.position(),\n                                                                                 input, input.position(), input.limit() - input.position(),","sourceCodeStart":143,"sourceCodeEnd":179,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/io/compress/ZstdDictionaryCompressor.java#L143-L179","documentation":"Thrown by ZstdDictionaryCompressor.uncompress when Zstd.decompressFastDict completes but returns an error code (Zstd.isError(dsz) is true). The message includes Zstd.getErrorName(dsz) identifying the exact zstd-level failure such as dstSizeTooSmall, srcSizeWrong, or corruption_detected. Unlike error 1360, this is a zstd error code rather than a thrown Java exception.","triggerScenarios":"uncompress(byte[], byte[], int) is called with an output buffer smaller than the decompressed size, an input length that does not match the compressed frame size, or corrupted input bytes — Zstd returns an error code instead of throwing.","commonSituations":"Underestimating the decompressed buffer size when using recomputedLength; passing concatenated or misaligned compressed chunks; bit-rot or partial disk reads.","solutions":["Read the specific zstd error name in the message (after 'due to ') to identify the failure","If the error is dstSizeTooSmall, allocate a larger output buffer (use the file's compressed metadata / chunkLength)","If srcSizeWrong, ensure the inputLength exactly matches the stored compressed chunk length","Treat the data as corrupt and re-fetch from a replica"],"exampleFix":"// before\nbyte[] out = new byte[guessedSize];\nint n = ...;\ncompressor.uncompress(in, out, 0); // may fail with dstSizeTooSmall\n// after\nint outSize = compressedChunk.uncompressedLength(); // from metadata\nbyte[] out = new byte[outSize];\ncompressor.uncompress(in, out, 0);","handlingStrategy":"try-catch","validationCode":"if (output.length < compressedChunk.uncompressedLength()) throw new IllegalArgumentException(\"output buffer too small\");","typeGuard":"boolean isZstdError(int code) { return code < 0; }","tryCatchPattern":"try { compressor.uncompress(input, output, 0); } catch (IOException e) { // message contains \"Decompression failed due to <ZstdErrorName>\"; parse and branch on error name }","preventionTips":["Size output buffers from the recorded uncompressed chunk length, never guessed","Ensure inputLength matches the exact compressed frame length","Use the error name after 'due to ' to distinguish buffer-size vs corruption issues","Enable checksums so corrupt chunks are detected upstream"],"tags":["io","zstd","decompression","buffer-size"],"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"}