{"record":{"id":"af81d6cf1bc6e037","repo":"apache/seatunnel","slug":"failed-to-read-schema-for-table-tableid-af81d6","errorCode":null,"errorMessage":"Failed to read schema for table ${tableId} ","messagePattern":"Failed to read schema for table (.+?) ","errorType":"exception","errorClass":"SeaTunnelException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-cdc/connector-cdc-postgres/src/main/java/org/apache/seatunnel/connectors/seatunnel/cdc/postgres/utils/PostgresSchema.java","lineNumber":85,"sourceCode":"                    tableIdWithoutCatalog.catalog(),\n                    tableIdWithoutCatalog.schema(),\n                    connectorConfig.getTableFilters().dataCollectionFilter(),\n                    null,\n                    false);\n            for (TableId id : tables.tableIds()) {\n                TableId idWithCatalog = new TableId(tableId.catalog(), id.schema(), id.table());\n                if (tableMap.containsKey(idWithCatalog)) {\n                    Table table =\n                            CatalogTableUtils.mergeCatalogTableConfig(\n                                    tables.forTable(id), tableMap.get(idWithCatalog));\n                    TableChanges.TableChange tableChange =\n                            new TableChanges.TableChange(\n                                    TableChanges.TableChangeType.CREATE, table);\n                    schemasByTableId.put(idWithCatalog, tableChange);\n                }\n            }\n        } catch (SQLException e) {\n            throw new SeaTunnelException(\n                    String.format(\"Failed to read schema for table %s \", tableId), e);\n        }\n\n        if (!schemasByTableId.containsKey(tableId)) {\n            throw new SeaTunnelException(\n                    String.format(\"Can't obtain schema for table %s \", tableId));\n        }\n\n        return schemasByTableId.get(tableId);\n    }\n}\n","sourceCodeStart":67,"sourceCodeEnd":97,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-cdc/connector-cdc-postgres/src/main/java/org/apache/seatunnel/connectors/seatunnel/cdc/postgres/utils/PostgresSchema.java#L67-L97","documentation":"PostgresSchema.readTableSchema queries PostgreSQL catalogs (via JDBC) to build the Table schema for a given TableId. If the JDBC query itself throws a SQLException, it is rethrown as a SeaTunnelException with 'Failed to read schema for table <id>' and the SQL error attached as the cause.","triggerScenarios":"The catalog query (information_schema / JDBC DatabaseMetaData calls) fails — connection error, insufficient privileges to read catalogs, invalid identifier passed to the query, or database unreachable while reading the schema before snapshotting/streaming starts.","commonSituations":"Wrong hostname/port/database in the CDC source config; the CDC user cannot see the schema (missing USAGE on schema); transient network failure during job startup; quoting issues with mixed-case identifiers.","solutions":["Inspect the chained cause for the real SQLException (connection refused vs privilege denied)","Verify connection parameters (host, port, database, user, password) with psql","Grant the CDC user USAGE on the schema and SELECT on the table / catalog visibility","Retry — transient network issues at startup are the common cause"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// check the connection and privileges before schema read\nSELECT has_schema_privilege('cdc_user','public','USAGE');","typeGuard":null,"tryCatchPattern":"try { schema = postgresSchema.getTableSchema(tableId); } catch (SeaTunnelException e) {\n    log.error(\"schema read failed: {}\", e.getCause(), e); throw e;\n}","preventionTips":["Validate host/port/db/credentials with psql before launching the job","Grant USAGE on schema and catalog visibility to the CDC user","Quote mixed-case identifiers consistently"],"tags":["postgres","schema","jdbc","sql"],"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-14T05:17:10.506Z"}