{"record":{"id":"abd7b361d01d1dcc","repo":"alibaba/canal","slug":"command-show-binlog-events-limit-1-has-an-erro-abd7b3","errorCode":null,"errorMessage":"command : 'show binlog events limit 1' has an error!","messagePattern":"command : 'show binlog events limit 1' has an error!","errorType":"exception","errorClass":"CanalParseException","httpStatus":null,"severity":"error","filePath":"parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/MysqlEventParser.java","lineNumber":718,"sourceCode":"    /**\n     * 查询当前的binlog位置\n     */\n    private EntryPosition findStartPosition(MysqlConnection mysqlConnection) {\n        try {\n            String showSql = \"show binlog events limit 1\";\n            if (multiStreamEnable) {\n                showSql = \"show binlog events with \" + destination + \" limit 1\";\n            }\n            ResultSetPacket packet = mysqlConnection.query(showSql);\n            List<String> fields = packet.getFieldValues();\n            if (CollectionUtils.isEmpty(fields)) {\n                throw new CanalParseException(\n                        \"command : 'show binlog events limit 1' has an error! pls check. you need (at least one of) the SUPER,REPLICATION CLIENT privilege(s) for this operation\");\n            }\n            EntryPosition endPosition = new EntryPosition(fields.get(0), Long.valueOf(fields.get(1)));\n            return endPosition;\n        } catch (IOException e) {\n            throw new CanalParseException(\"command : 'show binlog events limit 1' has an error!\", e);\n        }\n\n    }\n\n    /**\n     * 查询当前的slave视图的binlog位置\n     */\n    @SuppressWarnings(\"unused\")\n    private SlaveEntryPosition findSlavePosition(MysqlConnection mysqlConnection) {\n        try {\n            String showSql = \"show slave status\";\n            if (mysqlConnection.atLeastMySQL84()) {\n                // 兼容mysql 8.4\n                showSql = \"show replica status\";\n            }\n            ResultSetPacket packet = mysqlConnection.query(showSql);\n            List<FieldPacket> names = packet.getFieldDescriptors();\n            List<String> fields = packet.getFieldValues();","sourceCodeStart":700,"sourceCodeEnd":736,"githubUrl":"https://github.com/alibaba/canal/blob/87be50e87686a3e8af08c368d0e1ffd1f59eb04a/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/MysqlEventParser.java#L700-L736","documentation":"Thrown from the catch(IOException) block of findStartPosition() when the 'show binlog events limit 1' query itself fails at the transport/protocol level. Unlike error 400 (which fires on an empty-but-successful result), this wraps the underlying IOException — the MySQL server rejected the query, the connection dropped, or the socket read failed before any result packet arrived.","triggerScenarios":"mysqlConnection.query(showSql) throws an IOException during the binlog-events query. Causes include: the server actively denies the command (returns an error packet that the driver surfaces as IOException), the TCP connection was reset mid-query, the connection timed out, or the MySQL process was killed.","commonSituations":"The MySQL server has binlog disabled (log_bin=OFF) so the command fails. A firewall or load balancer killed the idle connection before the query ran. The MySQL server restarted between connection-establishment and position-discovery. Network latency caused a socket read timeout on a large binlog.","solutions":["Verify log_bin is ON: run 'SHOW VARIABLES LIKE \"log_bin\";' on the MySQL server.","Check network stability between the canal instance and MySQL host (firewall idle timeout, NAT, proxy).","Increase the socket read timeout in the canal JDBC URL (e.g. connectTimeout / socketTimeout parameters).","Confirm the MySQL server is reachable and not under extreme load at startup time."],"exampleFix":"# before\ncanal.instance.master.address=10.0.0.5:3306\n\n# after — add socket timeouts to the JDBC URL\ncanal.instance.master.address=10.0.0.5:3306\ncanal.instance.master.jdbc.url=jdbc:mysql://10.0.0.5:3306?connectTimeout=10000&socketTimeout=60000","handlingStrategy":"retry","validationCode":"// Check that log_bin is enabled before starting\nResultSetPacket rs = mysqlConnection.query(\"SHOW VARIABLES LIKE 'log_bin'\");\nString logBin = rs.getFieldValues().get(1);\nif (!\"ON\".equalsIgnoreCase(logBin)) {\n    throw new IllegalStateException(\"MySQL binlog is not enabled (log_bin=OFF)\");\n}","typeGuard":null,"tryCatchPattern":"int maxRetries = 3;\nfor (int attempt = 0; attempt < maxRetries; attempt++) {\n    try {\n        EntryPosition pos = findStartPosition(mysqlConnection);\n        break;\n    } catch (CanalParseException e) {\n        if (e.getCause() instanceof IOException && attempt < maxRetries - 1) {\n            Thread.sleep((attempt + 1) * 2000L);\n            mysqlConnection.reconnect();\n            continue;\n        }\n        throw e;\n    }\n}","preventionTips":["Configure JDBC URL with autoReconnect=true and appropriate socket timeouts.","Monitor MySQL server availability before Canal startup.","Use connection pool validation queries (SELECT 1) to detect dead connections early."],"tags":["mysql","network","binlog","io-exception","startup"],"backgroundTag":null,"analyzedSha":"87be50e87686a3e8af08c368d0e1ffd1f59eb04a","analyzedAt":"2026-08-14T04:30:11.918Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}