{"record":{"id":"64cdd66cec410eba","repo":"alibaba/canal","slug":"command-showsql-has-an-error","errorCode":null,"errorMessage":"command : ' + showSql + ' has an error!","messagePattern":"command : ' \\+ showSql \\+ ' 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":696,"sourceCode":"            if (CollectionUtils.isEmpty(fields)) {\n                throw new CanalParseException(\n                    \"command : '\" + showSql + \"' 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            if (isGTIDMode() && fields.size() > 4) {\n                endPosition.setGtid(fields.get(4));\n            }\n            // MariaDB 无法通过`show master status`获取 gtid\n            if (mysqlConnection.isMariaDB() && isGTIDMode()) {\n                ResultSetPacket gtidPacket = mysqlConnection.query(\"SELECT @@global.gtid_binlog_pos\");\n                List<String> gtidFields = gtidPacket.getFieldValues();\n                if (!CollectionUtils.isEmpty(gtidFields) && gtidFields.size() > 0) {\n                    endPosition.setGtid(gtidFields.get(0));\n                }\n            }\n            return endPosition;\n        } catch (IOException e) {\n            throw new CanalParseException(\"command : '\" + showSql + \"' has an error!\", e);\n        }\n    }\n\n    /**\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            }","sourceCodeStart":678,"sourceCodeEnd":714,"githubUrl":"https://github.com/alibaba/canal/blob/87be50e87686a3e8af08c368d0e1ffd1f59eb04a/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/MysqlEventParser.java#L678-L714","documentation":"findEndPosition()'s catch (IOException) wraps any transport/protocol failure of the `show master status` (or 8.4/multi-stream variant) query into CanalParseException. This is the I/O-failure counterpart to error 398 (which is the empty-result/privilege case). The showSql that failed is embedded in the message.","triggerScenarios":"The master-status query throws IOException — connection dropped, socket timeout, protocol error, or server-side abort during the query.","commonSituations":"Network instability to the master; connection killed by wait_timeout/idle; server failover mid-query; SSL/TLS handshake issue; firewall/proxy reset.","solutions":["Inspect the wrapped IOException cause (SocketTimeoutException, Connection reset, etc.) for the root transport failure.","Verify network path and increase defaultConnectionTimeoutInSeconds if queries time out.","Ensure canal's reconnect/HA logic re-establishes the connection and retries start-position discovery.","On MySQL 8.4, confirm the version detection picks `show binary log status` to avoid a syntax-driven IO error."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// Verify connectivity before master-status query\nif (!mysqlConnection.isConnected()) {\n    mysqlConnection.reconnect();\n}","typeGuard":null,"tryCatchPattern":"try {\n    return findEndPosition(mysqlConnection);\n} catch (CanalParseException e) {\n    if (e.getCause() instanceof IOException) {\n        logger.warn(\"Transient IO error reading master status, reconnecting and retrying once\", e);\n        mysqlConnection.reconnect();\n        return findEndPosition(mysqlConnection);\n    }\n    throw e;\n}","preventionTips":["Increase connection/socket timeouts for latent links.","Ensure reconnect/HA logic retries start-position discovery.","On MySQL 8.4, confirm version detection to use `show binary log status`."],"tags":["mysql","network","io","binlog","master-status","canal-parse"],"backgroundTag":null,"analyzedSha":"87be50e87686a3e8af08c368d0e1ffd1f59eb04a","analyzedAt":"2026-08-14T04:30:11.918Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}