{"record":{"id":"5613de116075c18a","repo":"apache/seatunnel","slug":"mysql-cdc-diagnostic-failed-to-query-mysql-server","errorCode":null,"errorMessage":"MySQL-CDC diagnostic: failed to query MySQL server identity: {}","messagePattern":"MySQL-CDC diagnostic: failed to query MySQL server identity: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"seatunnel-connectors-v2/connector-cdc/connector-cdc-mysql/src/main/java/org/apache/seatunnel/connectors/seatunnel/cdc/mysql/source/reader/fetch/MySqlSourceFetchTaskContext.java","lineNumber":477,"sourceCode":"            connection.query(\n                    sql,\n                    rs -> {\n                        if (!rs.next()) {\n                            return;\n                        }\n                        LOG.warn(\n                                \"MySQL-CDC diagnostic: connected to MySQL hostname={}, port={}, server_id={}, server_uuid={}, read_only={}, super_read_only={}, version={}, gtid_mode={}\",\n                                rs.getString(\"hostname\"),\n                                rs.getString(\"port\"),\n                                rs.getString(\"server_id\"),\n                                rs.getString(\"server_uuid\"),\n                                rs.getString(\"read_only\"),\n                                rs.getString(\"super_read_only\"),\n                                rs.getString(\"version\"),\n                                rs.getString(\"gtid_mode\"));\n                    });\n        } catch (SQLException e) {\n            LOG.warn(\n                    \"MySQL-CDC diagnostic: failed to query MySQL server identity: {}\",\n                    e.getMessage());\n        }\n    }\n\n    private void logMySqlBinlogRetentionVariables() {\n        logMySqlVariable(\"log_bin\");\n        logMySqlVariable(\"binlog_format\");\n        logMySqlVariable(\"binlog_expire_logs_seconds\");\n        logMySqlVariable(\"expire_logs_days\");\n    }\n\n    private void logMySqlVariable(String variableName) {\n        final String sql = String.format(\"SHOW VARIABLES LIKE '%s'\", variableName);\n        try {\n            connection.query(\n                    sql,\n                    rs -> {","sourceCodeStart":459,"sourceCodeEnd":495,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-cdc/connector-cdc-mysql/src/main/java/org/apache/seatunnel/connectors/seatunnel/cdc/mysql/source/reader/fetch/MySqlSourceFetchTaskContext.java#L459-L495","documentation":"Diagnostic WARN from logMySqlServerIdentity's catch block: the SQL query used to fetch server identity (server_id, uuid, gtid_mode, etc.) raised a SQLException, so the identity diagnostics could not be collected. The CDC task itself continues; only the diagnostic output is lost.","triggerScenarios":"The identity query fails due to lost connection, insufficient privileges to read the queried variables/information_schema, or the server rejecting the diagnostic SQL while handling a binlog/GTID unavailability condition.","commonSituations":"User lacks SELECT privilege on information_schema or SESSION_VARIABLES; connection dropped mid-diagnostic; firewall or proxy blocking the query.","solutions":["Grant the CDC user privileges to query system variables/information_schema (e.g. SELECT on *.* or PERFORMANCE_SCHEMA/session_variables)","Check network stability to the MySQL host; re-run the job and inspect earlier connection errors","If a proxy restricts queries, run the identity SQL manually with a DBA account to gather the same values"],"exampleFix":"// before\nGRANT SELECT ON db.* TO 'stuser'@'%';\n// after\nGRANT SELECT, RELOAD, REPLICATION CLIENT, REPLICATION SLAVE ON *.* TO 'stuser'@'%';","handlingStrategy":"try-catch","validationCode":"// Verify privileges and connectivity first\nmysql -h <host> -u stuser -p -e 'SELECT @@gtid_mode; SELECT @@server_uuid;'\nSHOW GRANTS FOR 'stuser'@'%';","typeGuard":null,"tryCatchPattern":"try {\n    runIdentityQuery(connection);\n} catch (SQLException e) {\n    LOG.warn(\"identity diagnostics skipped: {}\", e.getMessage());\n    // fall back to manual SHOW VARIABLES as DBA\n}","preventionTips":["Grant SELECT on information_schema/PERFORMANCE_SCHEMA and global variable read access to the CDC user","Keep connections alive across the diagnostic phase (avoid pool teardown mid-task)","Whitelist SHOW/SELECT diagnostics on DB proxies"],"tags":["mysql","cdc","diagnostics","sql","permissions"],"backgroundTag":"sql-query-failed","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}