{"record":{"id":"0adbb7fd5855fa0f","repo":"alibaba/canal","slug":"limit-excceed","errorCode":null,"errorMessage":"limit excceed: ","messagePattern":"limit excceed: ","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"dbsync/src/main/java/com/taobao/tddl/dbsync/binlog/LogBuffer.java","lineNumber":1776,"sourceCode":"                    break;\r\n                default:\r\n                    // bad algorithm\r\n                    return this;\r\n            }\r\n        } catch (Exception e) {\r\n            throw new IllegalArgumentException(\"uncompress failed \", e);\r\n        }\r\n\r\n        if (buffer.limit() != len) {\r\n            throw new IllegalArgumentException(\r\n                \"uncompress lenght not match, expected : \" + len + \" , but actual : \" + buffer.limit());\r\n        }\r\n        return buffer;\r\n    }\r\n\r\n    private LogBuffer uncompressZlib(int len) throws Exception {\r\n        if (position + len > limit || position < 0) {\r\n            throw new IllegalArgumentException(\"limit excceed: \" + (position + len));\r\n        }\r\n\r\n        try (DeflateCompressorInputStream in = new DeflateCompressorInputStream(\r\n            new ByteArrayInputStream(buffer, position, position + len))) {\r\n            byte[] decodeBytes = IOUtils.toByteArray(in);\r\n            return new LogBuffer(decodeBytes, 0, decodeBytes.length);\r\n        }\r\n    }\r\n\r\n    /**\r\n     * Return full hexdump from position.\r\n     */\r\n    public final String hexdump(final int pos) {\r\n        if ((limit - pos) > 0) {\r\n            final int begin = origin + pos;\r\n            final int end = origin + limit;\r\n\r\n            byte[] buf = buffer;\r","sourceCodeStart":1758,"sourceCodeEnd":1794,"githubUrl":"https://github.com/alibaba/canal/blob/87be50e87686a3e8af08c368d0e1ffd1f59eb04a/dbsync/src/main/java/com/taobao/tddl/dbsync/binlog/LogBuffer.java#L1758-L1794","documentation":"Thrown by uncompressZlib() before attempting decompression when the requested read range [position, position+len) exceeds the buffer's limit, or position is negative. This is a bounds check on the compressed data region within the LogBuffer before it is passed to DeflateCompressorInputStream. Note the typo 'excceed' in the message.","triggerScenarios":"uncompressZlib is called with len = limit - position (the remaining bytes). If position + len > limit or position < 0, the exception fires. This can happen if the buffer was already consumed past the compressed data region, or if limit was set incorrectly.","commonSituations":"Buffer position advanced past the compressed data by earlier parsing logic, an incorrect limit set during buffer creation, or a row event whose event length header is smaller than the actual compressed payload.","solutions":["Verify buffer.position() and buffer.limit() before calling uncompressBuf().","Check that the event's declared length matches the buffer's remaining bytes.","Trace the buffer position from the event header parse to find where it diverged.","Ensure no prior consume() or forward() call advanced position beyond the compressed data region."],"exampleFix":"// before\nLogBuffer decompressed = buffer.uncompressBuf();\n\n// after: pre-validate buffer state\nif (buffer.position() < 0 || buffer.remaining() <= 0) {\n    logger.warn(\"Buffer in invalid state for decompression: pos={}, limit={}\",\n        buffer.position(), buffer.limit());\n    return buffer;\n}\nLogBuffer decompressed = buffer.uncompressBuf();","handlingStrategy":"validation","validationCode":"// Pre-validate buffer state before decompression\nif (buffer.position() < 0 || buffer.position() > buffer.limit()) {\n    logger.warn(\"Buffer position {} is out of range [0, {}]\", buffer.position(), buffer.limit());\n    return buffer; // or throw a domain-specific exception\n}\nif (buffer.remaining() <= 0) {\n    logger.warn(\"No data remaining to decompress\");\n    return buffer;\n}","typeGuard":null,"tryCatchPattern":"try {\n    LogBuffer decompressed = buffer.uncompressBuf();\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().startsWith(\"limit excceed\")) {\n        logger.warn(\"Buffer bounds exceeded during decompression: pos={}, limit={}\",\n            buffer.position(), buffer.limit());\n    }\n    throw e;\n}","preventionTips":["Ensure buffer position is not advanced past the compressed data region before calling uncompressBuf.","Verify buffer limit matches the event's declared size.","Trace buffer position from event header parse to detect desynchronization."],"tags":["compression","binlog","mariadb","buffer-bounds","zlib"],"backgroundTag":null,"analyzedSha":"87be50e87686a3e8af08c368d0e1ffd1f59eb04a","analyzedAt":"2026-08-14T04:30:11.918Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}