{"record":{"id":"73b0a4cb1e3ff87a","repo":"apache/seatunnel","slug":"mysql-cdc-diagnostic-failed-to-query-variable","errorCode":null,"errorMessage":"MySQL-CDC diagnostic: failed to query variable {}: {}","messagePattern":"MySQL-CDC diagnostic: failed to query variable (.+?): (.+?)","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":506,"sourceCode":"    }\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 -> {\n                        if (!rs.next()) {\n                            LOG.warn(\"MySQL-CDC diagnostic: variable {} not found\", variableName);\n                            return;\n                        }\n                        LOG.warn(\n                                \"MySQL-CDC diagnostic: variable {}={}\",\n                                rs.getString(1),\n                                rs.getString(2));\n                    });\n        } catch (SQLException e) {\n            LOG.warn(\n                    \"MySQL-CDC diagnostic: failed to query variable {}: {}\",\n                    variableName,\n                    e.getMessage());\n        }\n    }\n\n    private void logMySqlMasterStatus() {\n        try {\n            connection.query(\n                    \"SHOW MASTER STATUS\",\n                    rs -> {\n                        if (!rs.next()) {\n                            LOG.warn(\n                                    \"MySQL-CDC diagnostic: SHOW MASTER STATUS returned empty result\");\n                            return;\n                        }\n                        String file = safeGetString(rs, \"File\");\n                        String position = safeGetString(rs, \"Position\");","sourceCodeStart":488,"sourceCodeEnd":524,"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#L488-L524","documentation":"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.","triggerScenarios":"SQLException during SHOW VARIABLES — dead connection, syntax/privilege rejection, or server errors while the diagnostic runs after a binlog/GTID availability failure.","commonSituations":"Connection pool closed before diagnostics run; restricted DB proxies blocking SHOW statements; insufficient privileges.","solutions":["Check the underlying connection health (earlier logs usually show the real connection error)","Run SHOW VARIABLES LIKE '<name>' manually as a DBA to get the value","Grant the CDC user privileges needed for SHOW VARIABLES (generally available, but proxies may restrict it)"],"exampleFix":"// before\nSHOW VARIABLES LIKE 'binlog_expire_logs_seconds'; -- denied by proxy\n// after: whitelist SHOW VARIABLES / run diagnostics on a direct connection","handlingStrategy":"try-catch","validationCode":"mysql -h <host> -u stuser -p -e \"SHOW VARIABLES LIKE 'binlog_expire_logs_seconds';\"","typeGuard":null,"tryCatchPattern":"try {\n    queryVariable(connection, variableName);\n} catch (SQLException e) {\n    LOG.warn(\"variable {} query failed: {}\", variableName, e.getMessage());\n    // obtain value manually via DBA session\n}","preventionTips":["Test all diagnostic SQL with the production CDC user before rollout","Avoid restrictive proxies between the CDC job and MySQL","Capture variable values via monitoring instead of ad-hoc queries when possible"],"tags":["mysql","cdc","diagnostics","sql","variables"],"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"}