alibaba/canal · error · IllegalArgumentException
uncompress failed
Error message
uncompress failed
What it means
A catch-all wrapper thrown when any Exception occurs during zlib decompression of a MariaDB compressed binlog event. The original exception is chained as the cause. The actual failure is inside uncompressZlib(), which uses Apache Commons Compress's DeflateCompressorInputStream to inflate the data.
Source
Thrown at dbsync/src/main/java/com/taobao/tddl/dbsync/binlog/LogBuffer.java:1764
*
* @return
*/
public LogBuffer uncompressBuf() {
int lenPad = getInt8();
long len = getUncompressLong(lenPad & 0x07);
int alg = (lenPad & 0x70) >> 4;
LogBuffer buffer = null;
try {
switch (alg) {
case 0:
buffer = uncompressZlib(limit - position);
break;
default:
// bad algorithm
return this;
}
} catch (Exception e) {
throw new IllegalArgumentException("uncompress failed ", e);
}
if (buffer.limit() != len) {
throw new IllegalArgumentException(
"uncompress lenght not match, expected : " + len + " , but actual : " + buffer.limit());
}
return buffer;
}
private LogBuffer uncompressZlib(int len) throws Exception {
if (position + len > limit || position < 0) {
throw new IllegalArgumentException("limit excceed: " + (position + len));
}
try (DeflateCompressorInputStream in = new DeflateCompressorInputStream(
new ByteArrayInputStream(buffer, position, position + len))) {
byte[] decodeBytes = IOUtils.toByteArray(in);
return new LogBuffer(decodeBytes, 0, decodeBytes.length);
View on GitHub (pinned to 87be50e876)
Solutions
- Examine the chained cause exception (e.getCause()) for the specific decompression failure — e.g., ZipException, EOFException, or DataFormatException.
- Verify the MariaDB server version and its binlog compression settings match what the parser expects.
- Check network reliability between the replicator and the MariaDB server — use TCP keepalive and proper timeouts.
- If the compressed payload is genuinely corrupt, skip the event and re-request from the last known-good binlog position.
Example fix
// before
LogBuffer decompressed = buffer.uncompressBuf();
// after: inspect the cause for diagnostics
try {
LogBuffer decompressed = buffer.uncompressBuf();
} catch (IllegalArgumentException e) {
Throwable root = e.getCause() != null ? e.getCause() : e;
logger.error("Binlog decompression failed at pos={}, root cause: {}",
buffer.position(), root.getClass().getSimpleName(), root);
throw e;
} Defensive patterns
Strategy: try-catch
Try / catch
try {
LogBuffer decompressed = buffer.uncompressBuf();
} catch (IllegalArgumentException e) {
Throwable cause = e.getCause();
logger.error("Binlog decompression failed, root cause: {}",
cause != null ? cause.getMessage() : "unknown", e);
// skip event or re-sync replication
} Prevention
- Verify MariaDB server binlog compression configuration matches parser expectations.
- Monitor replication network health — partial reads due to socket issues can corrupt compressed payloads.
- Enable binlog checksum verification to detect corruption before decompression.
When it happens
Trigger: LogBuffer.uncompressBuf() is called for a MariaDB compressed log event. The algorithm byte indicates zlib (alg=0), so uncompressZlib() is invoked. Any exception from the decompression (corrupt compressed stream, truncated data, invalid zlib header) is caught and re-thrown with this message.
Common situations: MariaDB binlog compression with a corrupt deflate stream, network-level data corruption during replication, partial event reads due to socket timeouts, or a version mismatch where the parser attempts to decompress data that is not actually compressed.
Related errors
- uncompress lenght not match, expected : , but actual :
- limit excceed:
- unknow compress type for :
- Invalid charset id: {}
- No such method: '{}' @ {}
AI-assisted analysis of alibaba/canal@87be50e876 (2026-08-14).
Data as JSON: /api/errors/cfb6225be6fc3919.
Report an issue: GitHub.