{"record":{"id":"756aa229ddcd4487","repo":"alibaba/canal","slug":"unexpected-binlog-format-query-result-rs-getfie","errorCode":null,"errorMessage":"unexpected binlog format query result: + rs.getFieldValues()","messagePattern":"unexpected binlog format query result: \\+ rs\\.getFieldValues\\(\\)","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/MysqlConnection.java","lineNumber":528,"sourceCode":"        }\n    }\n\n    /**\n     * 获取一下binlog format格式\n     */\n    private void loadBinlogFormat() {\n        ResultSetPacket rs = null;\n        try {\n            rs = query(\"show variables like 'binlog_format'\");\n        } catch (IOException e) {\n            throw new CanalParseException(e);\n        }\n\n        List<String> columnValues = rs.getFieldValues();\n        if (columnValues == null || columnValues.size() != 2) {\n            logger.warn(\n                \"unexpected binlog format query result, this may cause unexpected result, so throw exception to request network to io shutdown.\");\n            throw new IllegalStateException(\"unexpected binlog format query result:\" + rs.getFieldValues());\n        }\n\n        binlogFormat = BinlogFormat.valuesOf(columnValues.get(1));\n        if (binlogFormat == null) {\n            throw new IllegalStateException(\"unexpected binlog format query result:\" + rs.getFieldValues());\n        }\n    }\n\n    /**\n     * 获取一下binlog image格式\n     */\n    private void loadBinlogImage() {\n        ResultSetPacket rs = null;\n        try {\n            rs = query(\"show variables like 'binlog_row_image'\");\n        } catch (IOException e) {\n            throw new CanalParseException(e);\n        }","sourceCodeStart":510,"sourceCodeEnd":546,"githubUrl":"https://github.com/alibaba/canal/blob/87be50e87686a3e8af08c368d0e1ffd1f59eb04a/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/MysqlConnection.java#L510-L546","documentation":"loadBinlogFormat() runs `show variables like 'binlog_format'` and expects exactly 2 field values (variable name + value). If the result set is null or does not have exactly 2 columns, Canal throws IllegalStateException because it cannot safely determine the binlog format — continuing with an unknown format could misparse row events. This is a hard stop to force a connection teardown.","triggerScenarios":"The query returns zero rows (binlog_format variable not exposed to the session), an unexpected number of columns, or a null field list. This happens on privilege-restricted accounts or unusual server configurations where the variable is hidden.","commonSituations":"The canal DB user lacks permission to read session/global variables; connecting to a read-replica or proxy that strips variable queries; a non-MySQL-compatible server that does not expose binlog_format.","solutions":["Grant the account permission to read variables (REPLICATION CLIENT / PROCESS / SELECT on mysql, or SUPER as appropriate).","Manually run `show variables like 'binlog_format'` as the canal user to confirm it returns one row with two columns.","Ensure the target is a real MySQL/MariaDB master with binary logging enabled (log_bin=ON, binlog_format set to ROW)."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Pre-flight check the user can read binlog_format\nResultSetPacket rs = connection.query(\"show variables like 'binlog_format'\");\nList<String> vals = rs.getFieldValues();\nif (vals == null || vals.size() != 2) {\n    throw new IllegalStateException(\n        \"Cannot read binlog_format (got \" + vals + \"). Grant REPLICATION CLIENT/PROCESS to the canal user.\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pre-flight `show variables like 'binlog_format'` as the canal user before starting replication.","Grant REPLICATION CLIENT and SELECT/PROCESS privileges.","Confirm the target is a MySQL/MariaDB master with binary logging enabled."],"tags":["mysql","binlog-format","privilege","metadata-query","canal-parse"],"backgroundTag":null,"analyzedSha":"87be50e87686a3e8af08c368d0e1ffd1f59eb04a","analyzedAt":"2026-08-14T04:30:11.918Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}