apache/seatunnel · warning

MySQL-CDC diagnostic: failed to query variable {}: {}

Error message

MySQL-CDC diagnostic: failed to query variable {}: {}

What it means

Diagnostic WARN from logMySqlVariable's catch block: the SHOW VARIABLES LIKE query for a named variable raised a SQLException, so the variable's value could not be logged. Execution continues; only that retention-diagnostic data point is missing.

Source

Thrown at seatunnel-connectors-v2/connector-cdc/connector-cdc-mysql/src/main/java/org/apache/seatunnel/connectors/seatunnel/cdc/mysql/source/reader/fetch/MySqlSourceFetchTaskContext.java:506

    }

    private void logMySqlVariable(String variableName) {
        final String sql = String.format("SHOW VARIABLES LIKE '%s'", variableName);
        try {
            connection.query(
                    sql,
                    rs -> {
                        if (!rs.next()) {
                            LOG.warn("MySQL-CDC diagnostic: variable {} not found", variableName);
                            return;
                        }
                        LOG.warn(
                                "MySQL-CDC diagnostic: variable {}={}",
                                rs.getString(1),
                                rs.getString(2));
                    });
        } catch (SQLException e) {
            LOG.warn(
                    "MySQL-CDC diagnostic: failed to query variable {}: {}",
                    variableName,
                    e.getMessage());
        }
    }

    private void logMySqlMasterStatus() {
        try {
            connection.query(
                    "SHOW MASTER STATUS",
                    rs -> {
                        if (!rs.next()) {
                            LOG.warn(
                                    "MySQL-CDC diagnostic: SHOW MASTER STATUS returned empty result");
                            return;
                        }
                        String file = safeGetString(rs, "File");
                        String position = safeGetString(rs, "Position");

View on GitHub (pinned to cf67b549a7)

Solutions

  1. Check the underlying connection health (earlier logs usually show the real connection error)
  2. Run SHOW VARIABLES LIKE '<name>' manually as a DBA to get the value
  3. Grant the CDC user privileges needed for SHOW VARIABLES (generally available, but proxies may restrict it)

Example fix

// before
SHOW VARIABLES LIKE 'binlog_expire_logs_seconds'; -- denied by proxy
// after: whitelist SHOW VARIABLES / run diagnostics on a direct connection
Defensive patterns

Strategy: try-catch

Validate before calling

mysql -h <host> -u stuser -p -e "SHOW VARIABLES LIKE 'binlog_expire_logs_seconds';"

Try / catch

try {
    queryVariable(connection, variableName);
} catch (SQLException e) {
    LOG.warn("variable {} query failed: {}", variableName, e.getMessage());
    // obtain value manually via DBA session
}

Prevention

When it happens

Trigger: SQLException during SHOW VARIABLES — dead connection, syntax/privilege rejection, or server errors while the diagnostic runs after a binlog/GTID availability failure.

Common situations: Connection pool closed before diagnostics run; restricted DB proxies blocking SHOW statements; insufficient privileges.

Understand the failure class

Background: "query failed", "%w: SQL error" — wrapped database query errors in Go libraries explained — this error's family across 3 libraries.

Related errors


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