apache/seatunnel · warning · InterruptedException

Thread interrupted

Error message

Thread interrupted

What it means

JdbcDialect.sampleDataFromColumn samples values of a column (used e.g. to pick split keys) and checks Thread interruption inside the ResultSet loop, throwing InterruptedException('Thread interrupted') when the current thread has been interrupted. This is a cooperative-cancellation signal: the sampling query is being aborted (job cancel/stop or task shutdown) while reading rows.

Source

Thrown at seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/JdbcDialect.java:417

            sampleQuery =
                    String.format(
                            "SELECT %s FROM %s",
                            quoteIdentifier(columnName), tableIdentifier(table.getTablePath()));
        }

        try (PreparedStatement stmt = creatPreparedStatement(connection, sampleQuery, fetchSize)) {
            log.info(String.format("Split Chunk, approximateRowCntStatement: %s", sampleQuery));
            try (ResultSet rs = stmt.executeQuery()) {
                int count = 0;
                List<Object> results = new ArrayList<>();

                while (rs.next()) {
                    count++;
                    if (count % samplingRate == 0) {
                        results.add(rs.getObject(1));
                    }
                    if (Thread.currentThread().isInterrupted()) {
                        throw new InterruptedException("Thread interrupted");
                    }
                }
                Object[] resultsArray = results.toArray();
                Arrays.sort(resultsArray);
                return resultsArray;
            }
        }
    }

    /**
     * Query the maximum value of the next chunk, and the next chunk must be greater than or equal
     * to <code>includedLowerBound</code> value [min_1, max_1), [min_2, max_2),... [min_n, null).
     * Each time this method is called it will return max1, max2...
     *
     * @param connection JDBC connection.
     * @param table table info.
     * @param columnName column name.
     * @param chunkSize chunk size.

View on GitHub (pinned to cf67b549a7)

Solutions

  1. No fix needed if intentional cancellation — treat as cancellation, restore the interrupt flag and stop gracefully
  2. If unexpected, find who interrupted the thread (job cancellation logs) and address the upstream timeout/shutdown trigger
  3. Reduce sampling cost (raise samplingRate, index the sampled column) so sampling completes before cancellations occur
  4. Retry the job; this error is transient and tied to interruption, not data

Example fix

// before
try {
    results = dialect.sampleDataFromColumn(...);
} catch (InterruptedException e) { /* swallow */ }
// after
try {
    results = dialect.sampleDataFromColumn(...);
} catch (InterruptedException e) {
    Thread.currentThread().interrupt(); // restore flag
    throw new SeaTunnelRuntimeException(..., "sampling cancelled", e);
}
Defensive patterns

Strategy: try-catch

Try / catch

try {
    Object[] sample = dialect.sampleDataFromColumn(conn, table, column, samplingRate);
} catch (InterruptedException e) {
    Thread.currentThread().interrupt(); // restore cancel status
    throw new CancellationException("Sampling interrupted by job cancellation");
}

Prevention

When it happens

Trigger: The thread running the sampling query gets interrupted mid rs.next() iteration — typically during job cancellation, checkpoint/task cancellation, or shutdown — after at least `count % samplingRate == 0` iterations started.

Common situations: Cancelling a long-running SeaTunnel job while split enumeration is sampling large tables; job manager timeouts interrupting workers; manual kill/restart of the cluster during startup.

Understand the failure class

Background: Request timed out: what client-side request timeouts mean across libraries (Request timed out, TIMED_OUT, APITimeoutError) — this error's family across 39 libraries.

Related errors


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