{"record":{"id":"da4653420259a581","repo":"alibaba/canal","slug":"parse-failed","errorCode":null,"errorMessage":"parse failed","messagePattern":"parse failed","errorType":"exception","errorClass":"CanalParseException","httpStatus":null,"severity":"error","filePath":"parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/MysqlConnection.java","lineNumber":173,"sourceCode":"        if (StringUtils.isNotEmpty(gtid)) {\n            GTIDSet gtidSet = parseGtidSet(gtid, isMariaDB());\n            if (isMariaDB()) {\n                decoder.handle(LogEvent.GTID_EVENT);\n                decoder.handle(LogEvent.GTID_LIST_EVENT);\n            } else {\n                decoder.handle(LogEvent.GTID_LOG_EVENT);\n            }\n            context.setGtidSet(gtidSet);\n        }\n        context.setCompatiablePercona(compatiablePercona);\n        context.setFormatDescription(new FormatDescriptionLogEvent(4, binlogChecksum));\n        while (fetcher.fetch()) {\n            accumulateReceivedBytes(fetcher.limit());\n            LogEvent event = null;\n            event = decoder.decode(fetcher, context);\n\n            if (event == null) {\n                throw new CanalParseException(\"parse failed\");\n            }\n\n            if (!func.sink(event)) {\n                break;\n            }\n        }\n    }\n\n    public void dump(String binlogfilename, Long binlogPosition, SinkFunction func) throws IOException {\n        updateSettings();\n        loadBinlogChecksum();\n        loadVersionComment();\n        sendRegisterSlave();\n        sendBinlogDump(binlogfilename, binlogPosition);\n        DirectLogFetcher fetcher = new DirectLogFetcher(connector.getReceiveBufferSize());\n        fetcher.start(connector.getChannel());\n        LogDecoder decoder = new LogDecoder(LogEvent.UNKNOWN_EVENT, LogEvent.ENUM_END_EVENT);\n        LogContext context = new LogContext();","sourceCodeStart":155,"sourceCodeEnd":191,"githubUrl":"https://github.com/alibaba/canal/blob/87be50e87686a3e8af08c368d0e1ffd1f59eb04a/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/MysqlConnection.java#L155-L191","documentation":"Thrown as CanalParseException inside MysqlConnection.dump (the GTID-less filename+position variant) when decoder.decode(fetcher, context) returns null for an event that was fetched. A null event means the decoder could not produce a LogEvent from the bytes read, which Canal treats as an unrecoverable parse failure for that stream.","triggerScenarios":"While fetcher.fetch() returns true in the dump loop, decoder.decode returns null. Happens with a corrupted/truncated binlog event, an unsupported event type, a binlog format/version mismatch, or a checksum incompatibility between client and server.","commonSituations":"MySQL version/binlog format newer than the Canal driver supports, binlog_checksum enabled on the server but not negotiated, a partial event due to network truncation, or a corrupted relay/binlog. Also after a connector bug in event decoding.","solutions":["Check binlog_format is ROW and binlog_checksum matches what Canal negotiates (loadBinlogChecksum runs first).","Upgrade Canal/driver to a release that supports the MySQL version emitting the event.","If the binlog is corrupt/truncated, skip to the next valid position or restore from a clean binlog.","Inspect the bytes around the failure (event type/length) to identify an unsupported event code."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"-- confirm checksum/format compatibility before dump\nSHOW VARIABLES LIKE 'binlog_checksum';  -- ensure client negotiates it\nSHOW VARIABLES LIKE 'binlog_format';   -- expect ROW","typeGuard":null,"tryCatchPattern":"// decode-null is often transient corruption; bounded retry to next event\ntry { connection.dump(fn, pos, func); }\ncatch (CanalParseException e) {\n    if (\"parse failed\".equals(e.getMessage())) { pos = advancePastCurrentEvent(pos); retryWithinLimit(); }\n    else throw e;\n}","preventionTips":["Match binlog_checksum between server and Canal negotiation.","Upgrade Canal/driver for newer MySQL event types.","Use ROW binlog_format on the source."],"tags":["parse","binlog","decode","mysql-connection","version-compat"],"backgroundTag":null,"analyzedSha":"87be50e87686a3e8af08c368d0e1ffd1f59eb04a","analyzedAt":"2026-08-14T04:30:11.918Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}