{"record":{"id":"04249b8e1b16af61","repo":"apache/seatunnel","slug":"failed-to-read-schema-for-table-tableid","errorCode":null,"errorMessage":"Failed to read schema for table ${tableId}","messagePattern":"Failed to read schema for table (.+?)","errorType":"exception","errorClass":"SeaTunnelException","httpStatus":null,"severity":"critical","filePath":"seatunnel-connectors-v2/connector-cdc/connector-cdc-mysql/src/main/java/org/apache/seatunnel/connectors/seatunnel/cdc/mysql/utils/MySqlSchema.java","lineNumber":97,"sourceCode":"        return schema;\n    }\n\n    private TableChange readTableSchema(JdbcConnection jdbc, TableId tableId) {\n        Map<TableId, TableChange> tableChangeMap = new HashMap<>();\n        try {\n            tableChangeMap = getTableSchemaByShowCreateTable(jdbc, tableId);\n            if (tableChangeMap.isEmpty()) {\n                log.debug(\"Load schema is empty for table {}\", tableId);\n            }\n        } catch (Exception e) {\n            log.debug(\"Ignore exception when execute `SHOW CREATE TABLE {}` failed\", tableId, e);\n        }\n        if (tableChangeMap.isEmpty()) {\n            try {\n                log.info(\"Fallback to use `DESC {}` load schema\", tableId);\n                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        }","sourceCodeStart":79,"sourceCodeEnd":115,"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#L79-L115","documentation":"MySqlSchema.readTableSchema first tries information-schema-based loading; when empty it falls back to `DESC <table>`. If that fallback query throws SQLException it is wrapped in SeaTunnelException 'Failed to read schema for table <id>'.","triggerScenarios":"getTableSchema -> readTableSchema when the information-schema result is empty and the `DESC tableId` JDBC query fails with SQLException.","commonSituations":"Table dropped or renamed between split enumeration and schema read; user lacks privileges to describe the table; wrong database name case (case-sensitive Linux MySQL); connection failure.","solutions":["Check the wrapped SQLException cause for the exact error","Verify the table still exists (`SHOW TABLES LIKE ...`) and the database/table name casing matches the server","GRANT SELECT/DESCRIBE privileges on the table to the SeaTunnel user","Avoid DDL on the table while the CDC job starts"],"exampleFix":"// before\ntableId = new TableId(\"mydb\", null, \"MyTable\"); // Linux MySQL is case-sensitive\n// after\ntableId = new TableId(\"mydb\", null, \"mytable\"); // match lower_case_table_names reality","handlingStrategy":"validation","validationCode":"mysql -u seatunnel -p -e \"DESC mydb.mytable;\"\n// must succeed with the same user the connector uses","typeGuard":null,"tryCatchPattern":"try {\n    startCdcJob(config);\n} catch (Exception e) {\n    if (e.getMessage().contains(\"Failed to read schema for table\")) {\n        log.error(\"Check table existence, casing, and SELECT/DESCRIBE privileges\", e.getCause());\n    }\n}","preventionTips":["Verify table names and case in table-names config match the server","Do not drop/rename tables during job startup","Grant SELECT on all configured tables","Confirm lower_case_table_names behavior on Linux MySQL"],"tags":["mysql","cdc","schema","jdbc"],"backgroundTag":"schema-validation-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"}