apache/seatunnel · critical · ConnectException

Snapshotting of table ${table.id()} failed

Error message

Snapshotting of table ${table.id()} failed

What it means

In MySqlSnapshotSplitReadTask.createDataEventsForTable, a SQLException while executing the snapshot SELECT for a split is wrapped in a ConnectException: 'Snapshotting of table <id> failed'. The library throws this because the JDBC read of the table chunk could not be completed, so the snapshot data cannot be produced.

Source

Thrown at seatunnel-connectors-v2/connector-cdc/connector-cdc-mysql/src/main/java/org/apache/seatunnel/connectors/seatunnel/cdc/mysql/source/reader/fetch/scan/MySqlSnapshotSplitReadTask.java:253

                            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<MySqlPartition> getChangeRecordEmitter(
            MySqlSnapshotContext 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 static class MySqlSnapshotContext
            extends RelationalSnapshotChangeEventSource.RelationalSnapshotContext<
                    MySqlPartition, MySqlOffsetContext> {

View on GitHub (pinned to cf67b549a7)

Solutions

  1. Inspect the wrapped SQLException cause for the real reason
  2. Verify the SeaTunnel MySQL user has SELECT privilege on the table
  3. Increase JDBC timeouts (connectTimeout, socketTimeout) and MySQL net_write_timeout/net_read_timeout
  4. Reduce chunk/split size so each snapshot query runs shorter
  5. Avoid DDL on the table during snapshot phase

Example fix

// before
} catch (SQLException e) {
    throw new ConnectException("Snapshotting of table " + table.id() + " failed", e);
}
// after
// no code fix needed by user; ensure:
GRANT SELECT ON mydb.mytable TO 'seatunnel'@'%';
SET GLOBAL net_write_timeout = 600;
Defensive patterns

Strategy: validation

Validate before calling

mysql -u seatunnel -p -e "SELECT COUNT(*) FROM mydb.mytable; SHOW VARIABLES LIKE 'net_write_timeout';"

Try / catch

try {
    engine.execute(jobConfig);
} catch (Exception e) {
    if (e.getMessage().contains("Snapshotting of table")) {
        log.error("Snapshot SELECT failed; check cause and privileges", e);
    }
}

Prevention

When it happens

Trigger: The JDBC query executed for the table's snapshot split (via executeQuery) throws SQLException — connection failure, query timeout, permission denial, or the table being dropped/altered during snapshot.

Common situations: Snapshotting very large tables exceeding net_write_timeout / wait_timeout; user lacking SELECT privilege; MySQL connection dropped; table renamed/dropped mid-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/6d8aca185f814fa2. Report an issue: GitHub.