apache/seatunnel · error · DebeziumException

Unexpected error while connecting to MySQL and looking at gt

Error message

Unexpected error while connecting to MySQL and looking at gtid_purged variable: 

What it means

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.

Source

Thrown at seatunnel-connectors-v2/connector-cdc/connector-cdc-mysql/src/main/java/io/debezium/connector/mysql/MySqlConnection.java:346

     * Get the purged GTID values from MySQL (gtid_purged value)
     *
     * @return A GTID set; may be empty if not using GTIDs or none have been purged yet
     */
    public GtidSet purgedGtidSet() {
        try {
            return queryAndMap(
                    "SELECT @@global.gtid_purged",
                    rs -> {
                        if (rs.next() && rs.getMetaData().getColumnCount() > 0) {
                            return new GtidSet(
                                    rs.getString(
                                            1)); // GTID set, may be null, blank, or contain a GTID
                            // set
                        }
                        return new GtidSet("");
                    });
        } catch (SQLException e) {
            throw new DebeziumException(
                    "Unexpected error while connecting to MySQL and looking at gtid_purged variable: ",
                    e);
        }
    }

    /**
     * Determine if the current user has the named privilege. Note that if the user has the "ALL"
     * privilege this method returns {@code true}.
     *
     * @param grantName the name of the MySQL privilege; may not be null
     * @return {@code true} if the user has the named privilege, or {@code false} otherwise
     */
    public boolean userHasPrivileges(String grantName) {
        try {
            return queryAndMap(
                    "SHOW GRANTS FOR CURRENT_USER",
                    rs -> {
                        while (rs.next()) {

View on GitHub (pinned to cf67b549a7)

Solutions

  1. Verify MySQL connectivity and credentials
  2. Grant the CDC user privileges to read global variables
  3. Check the cause SQLException for the precise server error
  4. Review binlog expiry (binlog_expire_logs_seconds) so offsets stay valid

Example fix

// before
SET GLOBAL binlog_expire_logs_seconds = 600;
// after
SET GLOBAL binlog_expire_logs_seconds = 604800;
Defensive patterns

Strategy: validation

Validate before calling

try (Statement s = conn.createStatement()) { ResultSet rs = s.executeQuery("SHOW GLOBAL VARIABLES LIKE 'gtid_purged'"); rs.next(); }

Try / catch

catch (DebeziumException e) { logger.error("Failed to read gtid_purged", e.getCause()); /* re-snapshot if purged set is unavailable */ }

Prevention

When it happens

Trigger: SQLException while querying @@GLOBAL.gtid_purged inside purgedGtidSet — lost connection, missing privileges, or rejected statement.

Common situations: Binlog purge ran aggressively on the server while connector was offline; connection misconfigurations; CDC user lacking SELECT on global variables.

Understand the failure class

Background: Database query failed: Internal Server Error 500s wrapping SQL, Prisma, and connection failures — what to check first — this error's family across 16 libraries.

Related errors


AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10). Data as JSON: /api/errors/8b5b5496ace79ad1. Report an issue: GitHub.