apache/seatunnel · error · RuntimeException

Failed to split chunks for table " + tableId

Error message

Failed to split chunks for table " + tableId

What it means

Wraps a SQLException raised while splitTableIntoChunks() executes the queries that probe the split column's min/max values and chunk boundaries. The connector rethrows it as a RuntimeException naming the table. It means the chunking SQL itself failed, not the overall table discovery.

Source

Thrown at seatunnel-connectors-v2/connector-cdc/connector-cdc-base/src/main/java/org/apache/seatunnel/connectors/cdc/base/source/enumerator/splitter/AbstractJdbcSourceChunkSplitter.java:103

            if (splitColumn == null) {
                if (sourceConfig.isExactlyOnce()) {
                    throw new UnsupportedOperationException(
                            String.format(
                                    "Exactly once is enabled, but not found primary key or unique key for table %s",
                                    tableId));
                }
                SnapshotSplit singleSplit = createSnapshotSplit(jdbc, tableId, 0, null, null, null);
                splits.add(singleSplit);
                log.warn(
                        "No evenly split column found for table {}, use single split {}",
                        tableId,
                        singleSplit);
            } else {
                final List<ChunkRange> chunks;
                try {
                    chunks = splitTableIntoChunks(jdbc, tableId, splitColumn);
                } catch (SQLException e) {
                    throw new RuntimeException("Failed to split chunks for table " + tableId, e);
                }

                // convert chunks into splits
                SeaTunnelRowType splitType = getSplitType(splitColumn);
                for (int i = 0; i < chunks.size(); i++) {
                    ChunkRange chunk = chunks.get(i);
                    SnapshotSplit split =
                            createSnapshotSplit(
                                    jdbc,
                                    tableId,
                                    i,
                                    splitType,
                                    chunk.getChunkStart(),
                                    chunk.getChunkEnd());
                    splits.add(split);
                }
            }

View on GitHub (pinned to cf67b549a7)

Solutions

  1. Read the chained SQLException for the exact SQL error
  2. Verify the CDC user has SELECT privilege on the target table (chunking samples min/max)
  3. Check DB connectivity/timeouts; raise wait_timeout or connector connection settings for long-running queries
  4. Retry the job if the failure was a transient connection drop
Defensive patterns

Strategy: retry

Validate before calling

// Pre-check SELECT privilege and run a boundary probe:
SELECT MIN(pk), MAX(pk) FROM db.t; -- run with the CDC user before the job

Try / catch

try { chunks = splitTableIntoChunks(jdbc, tableId, splitColumn); }
catch (SQLException e) {
  if (isTransient(e)) { retryWithBackoff(3); } else { throw new RuntimeException("Failed to split chunks for " + tableId, e); }
}

Prevention

When it happens

Trigger: generateSplits() -> splitTableIntoChunks(jdbc, tableId, splitColumn) throws SQLException (query timeout, permission denied on the table, numeric/date overflow in boundary computation, connection dropped mid-query).

Common situations: CDC user lacks SELECT on the table; very large tables causing slow boundary queries that hit network/timeout limits; connection killed by the DB (wait_timeout); datatype-specific failures casting min/max values.

Understand the failure class

Background: "query failed", "%w: SQL error" — wrapped database query errors in Go libraries explained — this error's family across 3 libraries.

Related errors


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