{"record":{"id":"7237b50a9ef2f622","repo":"apache/seatunnel","slug":"snapshotting-of-table-table-id-failed-7237b5","errorCode":null,"errorMessage":"Snapshotting of table ${table.id()} failed","messagePattern":"Snapshotting of table (.+?) failed","errorType":"exception","errorClass":"ConnectException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-cdc/connector-cdc-postgres/src/main/java/org/apache/seatunnel/connectors/seatunnel/cdc/postgres/source/reader/snapshot/PostgresSnapshotSplitReadTask.java","lineNumber":270,"sourceCode":"                            snapshotSplit.splitId(),\n                            Strings.duration(stop - exportStart));\n                    snapshotProgressListener.rowsScanned(\n                            snapshotContext.partition, table.id(), rows);\n                    logTimer = getTableScanLogTimer();\n                }\n                dispatcher.dispatchSnapshotEvent(\n                        snapshotContext.partition,\n                        table.id(),\n                        getChangeRecordEmitter(snapshotContext, table.id(), row),\n                        snapshotReceiver);\n            }\n            log.info(\n                    \"Finished exporting {} records for split '{}', total duration '{}'\",\n                    rows,\n                    snapshotSplit.splitId(),\n                    Strings.duration(clock.currentTimeInMillis() - exportStart));\n        } catch (SQLException e) {\n            throw new ConnectException(\"Snapshotting of table \" + table.id() + \" failed\", e);\n        }\n    }\n\n    protected ChangeRecordEmitter getChangeRecordEmitter(\n            PostgresSnapshotContext snapshotContext, TableId tableId, Object[] row) {\n        snapshotContext.offset.event(tableId, clock.currentTime());\n        return new SnapshotChangeRecordEmitter(\n                snapshotContext.partition, snapshotContext.offset, row, clock);\n    }\n\n    private Threads.Timer getTableScanLogTimer() {\n        return Threads.timer(clock, LOG_INTERVAL);\n    }\n\n    private Object readField(ResultSet rs, int columnIndex) throws SQLException {\n        final ResultSetMetaData metaData = rs.getMetaData();\n        final int columnType = metaData.getColumnType(columnIndex);\n","sourceCodeStart":252,"sourceCodeEnd":288,"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/source/reader/snapshot/PostgresSnapshotSplitReadTask.java#L252-L288","documentation":"createDataEventsForTable executes the snapshot SELECT (chunk query) for a table via JDBC and wraps any SQLException in a Debezium ConnectException with the message 'Snapshotting of table <id> failed', chaining the original SQL error as the cause. It signals that the bulk export of rows for one snapshot split could not be completed.","triggerScenarios":"The JDBC statement that reads rows for the snapshot split throws — connection dropped mid-snapshot, statement timeout, permission denied on SELECT, the table was dropped/locked, serialization or out-of-memory during result fetch.","commonSituations":"Network interruption between SeaTunnel worker and Postgres during a long snapshot; the snapshot user lacking SELECT on the table; PostgreSQL restart or failover mid-job; statement_timeout cancelling the long-running snapshot query.","solutions":["Read the chained cause (getCause()) to identify the underlying SQLException","Check the CDC user has SELECT privilege on the snapshot tables and required schemas","Increase statement_timeout / idle connection timeouts and verify network stability for long snapshots","Re-run the job — snapshot splits are restartable; if the table was dropped, restore it or remove it from the config"],"exampleFix":"// diagnose\ntry { ... } catch (ConnectException e) {\n    log.error(\"snapshot failed: {}\", e.getCause()); // real SQLException\n}","handlingStrategy":"retry","validationCode":"// preflight: SELECT privilege + reachability\ntry (Statement s = conn.createStatement(); ResultSet rs = s.executeQuery(\"SELECT 1 FROM \" + tableId.table() + \" LIMIT 1\")) { rs.next(); }","typeGuard":null,"tryCatchPattern":"try { task.createDataEvents(ctx); } catch (ConnectException e) {\n    Throwable root = e.getCause();\n    log.error(\"Snapshot of {} failed: {}\", tableId, root == null ? e : root.getMessage());\n    // snapshot splits are restartable — safe to retry\n}","preventionTips":["Grant SELECT on all snapshot tables to the CDC user","Tune statement_timeout and TCP keepalives for long snapshots","Avoid failovers/DML-heavy maintenance windows during initial snapshot"],"tags":["postgres","cdc","snapshot","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"}