apache/seatunnel · error · org.apache.kafka.connect.errors.ConnectException

Snapshotting of table failed

Error message

Snapshotting of table  failed

What it means

During snapshot data export, reading rows from the snapshot JDBC query threw a SQLException, so the task aborts with ConnectException 'Snapshotting of table <tableId> failed'. Note the message may render as 'Snapshotting of table failed' when table id formatting/interpolation is empty in some code paths.

Source

Thrown at seatunnel-connectors-v2/connector-cdc/connector-cdc-db2/src/main/java/org/apache/seatunnel/connectors/seatunnel/cdc/db2/source/reader/fetch/scan/Db2SnapshotSplitReadTask.java:238

                            snapshotSplit.splitId(),
                            Strings.duration(stop - exportStart));
                    snapshotProgressListener.rowsScanned(
                            snapshotContext.partition, table.id(), rows);
                    logTimer = getTableScanLogTimer();
                }
                dispatcher.dispatchSnapshotEvent(
                        snapshotContext.partition,
                        table.id(),
                        getChangeRecordEmitter(snapshotContext, table.id(), row),
                        snapshotReceiver);
            }
            log.info(
                    "Finished exporting {} records for split '{}', total duration '{}'",
                    rows,
                    snapshotSplit.splitId(),
                    Strings.duration(clock.currentTimeInMillis() - exportStart));
        } catch (SQLException e) {
            throw new ConnectException("Snapshotting of table " + table.id() + " failed", e);
        }
    }

    protected ChangeRecordEmitter getChangeRecordEmitter(
            Db2SnapshotContext snapshotContext, TableId tableId, Object[] row) {
        snapshotContext.offset.event(tableId, clock.currentTime());
        return new SnapshotChangeRecordEmitter(
                snapshotContext.partition, snapshotContext.offset, row, clock);
    }

    private Threads.Timer getTableScanLogTimer() {
        return Threads.timer(clock, LOG_INTERVAL);
    }

    private Object readField(ResultSet rs, int columnIndex) throws SQLException {
        final ResultSetMetaData metaData = rs.getMetaData();
        final int columnType = metaData.getColumnType(columnIndex);

View on GitHub (pinned to cf67b549a7)

Solutions

  1. Check the wrapped SQLException in logs for the exact DB2 SQLCODE and fix accordingly
  2. Grant SELECT privileges on the snapshot tables to the CDC user
  3. Avoid DDL/maintenance operations on tables during snapshots
  4. Increase JDBC query/socket timeouts and retry the job
Defensive patterns

Strategy: retry

Validate before calling

// preflight: ensure SELECT privilege and connectivity
SELECT COUNT(*) FROM <table>;

Try / catch

try { runPipeline(); } catch (ConnectException e) { if (e.getMessage().startsWith("Snapshotting of table")) { fixDb2AccessOrStability(); retry(); } }

Prevention

When it happens

Trigger: Executing the snapshot SELECT for a table and receiving a SQLException — connection loss, query timeout, insufficient SELECT privileges, or the table being dropped/altered during the snapshot.

Common situations: Long-running snapshots hitting network idle timeouts; DB2 killing long queries; missing read permissions; DBA running maintenance (REORG, table move) during the snapshot.

Understand the failure class

Background: Database query failed: Internal Server Error 500s wrapping SQL, Prisma, and connection failures — what to check first — this error's family across 16 libraries.

Related errors


AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10). Data as JSON: /api/errors/1c61ab3131a76bdb. Report an issue: GitHub.