{"record":{"id":"b80b23c1c404db08","repo":"apache/seatunnel","slug":"failed-to-read-schema-for-table-s-b80b23","errorCode":null,"errorMessage":"Failed to read schema for table %s","messagePattern":"Failed to read schema for table (.+?)","errorType":"exception","errorClass":"SeaTunnelException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-cdc/connector-cdc-mysql/src/main/java/org/apache/seatunnel/connectors/seatunnel/cdc/mysql/utils/MySqlSchema.java","lineNumber":113,"sourceCode":"                tableChangeMap = getTableSchemaByDescTable(jdbc, tableId);\n            } catch (SQLException ex) {\n                throw new SeaTunnelException(\n                        String.format(\"Failed to read schema for table %s\", tableId), ex);\n            }\n        }\n        if (!tableChangeMap.containsKey(tableId)) {\n            throw new RuntimeException(String.format(\"Can't obtain schema for table %s\", tableId));\n        }\n\n        return tableChangeMap.get(tableId);\n    }\n\n    @VisibleForTesting\n    public TableChange readTableSchemaByDesc(JdbcConnection jdbc, TableId tableId) {\n        try {\n            return getTableSchemaByDescTable(jdbc, tableId).get(tableId);\n        } catch (SQLException ex) {\n            throw new SeaTunnelException(\n                    String.format(\"Failed to read schema for table %s\", tableId), ex);\n        }\n    }\n\n    private Map<TableId, TableChange> getTableSchemaByShowCreateTable(\n            JdbcConnection jdbc, TableId tableId) throws SQLException {\n        AtomicReference<String> ddl = new AtomicReference<>();\n        String sql = SHOW_CREATE_TABLE + MySqlUtils.quote(tableId);\n        jdbc.query(\n                sql,\n                rs -> {\n                    rs.next();\n                    ddl.set(rs.getString(2));\n                });\n        return parseSnapshotDdl(tableId, ddl.get());\n    }\n\n    private Map<TableId, TableChange> getTableSchemaByDescTable(","sourceCodeStart":95,"sourceCodeEnd":131,"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/utils/MySqlSchema.java#L95-L131","documentation":"MySqlSchema.readTableSchemaByDesc wraps any SQLException raised while reading a table's schema via `DESC <table>` into a SeaTunnelException with this message. The library throws it because schema discovery (needed for CDC type mapping) failed at the JDBC level; the original SQLException is preserved as the cause. It indicates the connector could not introspect the table structure, not a data-read problem.","triggerScenarios":"Calling readTableSchemaByDesc (via tableChangeByDesc) when the DESCRIBE statement against MySQL fails: table dropped/renamed between discovery and schema read, insufficient privileges (no DESC permission), connection broken, or MySQL server error during query execution.","commonSituations":"CDC job reads a table that was dropped mid-job; a user with only SELECT on some tables tries to snapshot others; network drop or MySQL restart during schema read; firewall/proxy killing idle JDBC connections.","solutions":["Verify the table still exists in MySQL (SHOW TABLES / DESC the table manually) and recreate or exclude it if dropped","Grant the CDC user schema-introspection privileges (SELECT on the table plus metadata access) and rerun","Check JDBC connectivity to MySQL (network, firewall, server uptime) and retry the job","Inspect the wrapped SQLException cause for the exact MySQL error code and address it specifically"],"exampleFix":"// before\nTableChange change = schema.readTableSchemaByDesc(jdbc, tableId);\n// after\ntry {\n    TableChange change = schema.readTableSchemaByDesc(jdbc, tableId);\n} catch (SeaTunnelException e) {\n    LOG.warn(\"Table {} unavailable for CDC, skipping\", tableId, e.getCause());\n}","handlingStrategy":"try-catch","validationCode":"try (Statement st = conn.createStatement()) {\n    ResultSet rs = st.executeQuery(\"DESC `\" + table + \"`\");\n    if (!rs.next()) throw new IllegalStateException(\"Table \" + table + \" not readable\");\n}","typeGuard":"boolean tableReadable(Connection c, String table) {\n    try (ResultSet rs = c.createStatement().executeQuery(\n            \"SELECT 1 FROM information_schema.tables WHERE table_schema=DATABASE() AND table_name='\" + table + \"'\")) {\n        return rs.next();\n    } catch (SQLException e) { return false; }\n}","tryCatchPattern":"try {\n    TableChange change = schema.readTableSchemaByDesc(jdbc, tableId);\n} catch (SeaTunnelException e) {\n    if (e.getCause() instanceof SQLException) { /* log cause, skip or fail table */ }\n}","preventionTips":["Grant the CDC user DESC/metadata privileges on all listed tables","Exclude volatile/temporary tables from the CDC table list","Keep JDBC connections alive (proper timeouts, no aggressive firewall idle kills)","Pre-check table existence before starting the job"],"tags":["mysql","cdc","jdbc","schema-introspection"],"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-23T08:17:48.524Z"}