{"record":{"id":"8b5b5496ace79ad1","repo":"apache/seatunnel","slug":"unexpected-error-while-connecting-to-mysql-and-loo-8b5b54","errorCode":null,"errorMessage":"Unexpected error while connecting to MySQL and looking at gtid_purged variable: ","messagePattern":"Unexpected error while connecting to MySQL and looking at gtid_purged variable: ","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":346,"sourceCode":"     * Get the purged GTID values from MySQL (gtid_purged value)\n     *\n     * @return A GTID set; may be empty if not using GTIDs or none have been purged yet\n     */\n    public GtidSet purgedGtidSet() {\n        try {\n            return queryAndMap(\n                    \"SELECT @@global.gtid_purged\",\n                    rs -> {\n                        if (rs.next() && rs.getMetaData().getColumnCount() > 0) {\n                            return new GtidSet(\n                                    rs.getString(\n                                            1)); // GTID set, may be null, blank, or contain a GTID\n                            // set\n                        }\n                        return new GtidSet(\"\");\n                    });\n        } catch (SQLException e) {\n            throw new DebeziumException(\n                    \"Unexpected error while connecting to MySQL and looking at gtid_purged variable: \",\n                    e);\n        }\n    }\n\n    /**\n     * Determine if the current user has the named privilege. Note that if the user has the \"ALL\"\n     * privilege this method returns {@code true}.\n     *\n     * @param grantName the name of the MySQL privilege; may not be null\n     * @return {@code true} if the user has the named privilege, or {@code false} otherwise\n     */\n    public boolean userHasPrivileges(String grantName) {\n        try {\n            return queryAndMap(\n                    \"SHOW GRANTS FOR CURRENT_USER\",\n                    rs -> {\n                        while (rs.next()) {","sourceCodeStart":328,"sourceCodeEnd":364,"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#L328-L364","documentation":"purgedGtidSet reads the gtid_purged global variable from MySQL and wraps any SQLException into this DebeziumException. It means the connector could not learn which GTIDs have been purged from the binlogs, which is required to validate a stored offset/starting position.","triggerScenarios":"SQLException while querying @@GLOBAL.gtid_purged inside purgedGtidSet — lost connection, missing privileges, or rejected statement.","commonSituations":"Binlog purge ran aggressively on the server while connector was offline; connection misconfigurations; CDC user lacking SELECT on global variables.","solutions":["Verify MySQL connectivity and credentials","Grant the CDC user privileges to read global variables","Check the cause SQLException for the precise server error","Review binlog expiry (binlog_expire_logs_seconds) so offsets stay valid"],"exampleFix":"// before\nSET GLOBAL binlog_expire_logs_seconds = 600;\n// after\nSET GLOBAL binlog_expire_logs_seconds = 604800;","handlingStrategy":"validation","validationCode":"try (Statement s = conn.createStatement()) { ResultSet rs = s.executeQuery(\"SHOW GLOBAL VARIABLES LIKE 'gtid_purged'\"); rs.next(); }","typeGuard":null,"tryCatchPattern":"catch (DebeziumException e) { logger.error(\"Failed to read gtid_purged\", e.getCause()); /* re-snapshot if purged set is unavailable */ }","preventionTips":["Set generous binlog_expire_logs_seconds so offsets stay valid","Grant CDC user access to global variables","Take a fresh snapshot if binlogs were purged while offline","Monitor binlog disk usage and purge policy"],"tags":["mysql","gtid","binlog","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"}