{"record":{"id":"b3e450a95e78b44d","repo":"apache/seatunnel","slug":"unexpected-error-while-connecting-to-mysql-and-loo","errorCode":null,"errorMessage":"Unexpected error while connecting to MySQL and looking at GTID mode: ","messagePattern":"Unexpected error while connecting to MySQL and looking at GTID mode: ","errorType":"exception","errorClass":"DebeziumException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-cdc/connector-cdc-mysql/src/main/java/io/debezium/connector/mysql/MySqlConnection.java","lineNumber":274,"sourceCode":"\n    /**\n     * Determine whether the MySQL server has GTIDs enabled.\n     *\n     * @return {@code false} if the server's {@code gtid_mode} is set and is {@code OFF}, or {@code\n     *     true} otherwise\n     */\n    public boolean isGtidModeEnabled() {\n        try {\n            return queryAndMap(\n                    \"SHOW GLOBAL VARIABLES LIKE 'GTID_MODE'\",\n                    rs -> {\n                        if (rs.next()) {\n                            return !\"OFF\".equalsIgnoreCase(rs.getString(2));\n                        }\n                        return false;\n                    });\n        } catch (SQLException e) {\n            throw new DebeziumException(\n                    \"Unexpected error while connecting to MySQL and looking at GTID mode: \", e);\n        }\n    }\n\n    /**\n     * Determine the executed GTID set for MySQL.\n     *\n     * @return the string representation of MySQL's GTID sets; never null but an empty string if the\n     *     server does not use GTIDs\n     */\n    public String knownGtidSet() {\n        try {\n            return queryAndMap(\n                    binaryLogStatusStatement(),\n                    rs -> {\n                        if (rs.next() && rs.getMetaData().getColumnCount() > 4) {\n                            return rs.getString(\n                                    5); // GTID set, may be null, blank, or contain a GTID set","sourceCodeStart":256,"sourceCodeEnd":292,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-cdc/connector-cdc-mysql/src/main/java/io/debezium/connector/mysql/MySqlConnection.java#L256-L292","documentation":"isGtidModeEnabled queries the server (SELECT @@GLOBAL.gtid_mode) to determine whether GTID replication is on, and wraps any SQLException into this DebeziumException. The message text mentions GTID mode even though the real failure is the underlying query/connection error preserved as cause.","triggerScenarios":"SQLException while executing the GTID-mode query inside isGtidModeEnabled: connection lost, credentials invalid, or server refusing the statement.","commonSituations":"MySQL connection dropped during startup validation; user lacking privileges to read global variables; network interruption or DB failover while the connector checks GTID mode.","solutions":["Reconnect/verify the MySQL connection is healthy and credentials are valid","Check the user has privileges to query @@GLOBAL.gtid_mode","Inspect the cause SQLException for the actual root error and address it","Retry the connector after resolving network/database issues"],"exampleFix":"// before: user without privileges\nCREATE USER 'cdc'@'%' IDENTIFIED BY 'pw';\n// after\nGRANT SELECT ON *.* TO 'cdc'@'%';","handlingStrategy":"retry","validationCode":"try (Connection c = DriverManager.getConnection(url, user, pass); Statement s = c.createStatement()) { s.executeQuery(\"SELECT @@GLOBAL.gtid_mode\"); }","typeGuard":null,"tryCatchPattern":"catch (DebeziumException e) { logger.error(\"GTID mode check failed\", e.getCause()); retryWithBackoff(); }","preventionTips":["Health-check the MySQL endpoint before connector startup","Grant the CDC user privileges for global variable queries","Add retry with backoff around startup validation","Watch server logs during failovers"],"tags":["mysql","gtid","jdbc","cdc"],"backgroundTag":"database-query-failed","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}