apache/cassandra · critical · java.io.IOException

Decompression failed

Error message

Decompression failed

What it means

ZstdCompressorBase.uncompress(byte[], ...) wraps any exception thrown by the zstd-jni Zstd.decompressByteArray call in an IOException with the message 'Decompression failed', preserving the cause. This indicates zstd itself rejected the frame (malformed data, wrong magic number, corruption) as opposed to a checksum error reported separately.

Source

Thrown at src/java/org/apache/cassandra/io/compress/ZstdCompressorBase.java:119

     * @param inputLength
     * @param output
     * @param outputOffset
     * @return
     * @throws IOException
     */
    @Override
    public int uncompress(byte[] input, int inputOffset, int inputLength, byte[] output, int outputOffset)
    throws IOException
    {
        long dsz;
        try
        {
            dsz = Zstd.decompressByteArray(output, outputOffset, output.length - outputOffset,
                                           input, inputOffset, inputLength);
        }
        catch (Exception e)
        {
            throw new IOException("Decompression failed", e);
        }

        if (Zstd.isError(dsz))
            throw new IOException("Decompression failed due to " + Zstd.getErrorName(dsz));

        return (int) dsz;
    }

    /**
     * Decompress data via ByteBuffers
     *
     * @param input
     * @param output
     * @throws IOException
     */
    @Override
    public void uncompress(ByteBuffer input, ByteBuffer output) throws IOException
    {

View on GitHub (pinned to 88fd0f6a0e)

Solutions

  1. Inspect the wrapped cause (getCause()) to see the exact zstd error and confirm whether data is corrupt or offsets are wrong.
  2. Run `nodetool verify`/`scrub` on affected SSTables and repair from healthy replicas (`nodetool repair`).
  3. Restore the affected files from backup, or confirm the chunk is being read with the correct compressor class and offsets.

Example fix

// before: wrong offsets passed to uncompress
compressor.uncompress(buf, 0, buf.length, out, 0);
// after: use the chunk's real compressed length
compressor.uncompress(buf, 0, compressedLength, out, 0);
Defensive patterns

Strategy: try-catch

Try / catch

try {
    zstd.uncompress(input, inputOffset, inputLen, output, outputOffset);
} catch (IOException e) {
    logger.error("Zstd decompression failed: " + e.getCause(), e);
    // fail read, retry from another replica, or mark sstable corrupt
}

Prevention

When it happens

Trigger: Calling ZstdCompressor.uncompress on a byte array that is not a valid zstd frame — corrupt or truncated chunk data, wrong offsets (inputOffset/inputLength pointing at garbage), or data produced by a different compressor.

Common situations: Reading a damaged SSTable from failing disk; restoring a botched backup; pointing a reader at data compressed with a different algorithm; JNI/library version incompatibilities.

Related errors


AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10). Data as JSON: /api/errors/48b06bfe8f116b8a. Report an issue: GitHub.