apache/seatunnel · warning · InterruptedException

Thread interrupted

Error message

Thread interrupted

What it means

MysqlDialect.sampleDataFromColumn samples column values via a JDBC ResultSet to estimate split boundaries. During result iteration it checks Thread.currentThread().isInterrupted() and throws InterruptedException to abort sampling promptly when the task thread is interrupted (e.g. job cancel/checkpoint timeout). It is a cooperative-cancellation signal, not a data error.

Source

Thrown at seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/mysql/MysqlDialect.java:186

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

        try (Statement stmt =
                connection.createStatement(
                        ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY)) {
            stmt.setFetchSize(Integer.MIN_VALUE);
            try (ResultSet rs = stmt.executeQuery(sampleQuery)) {
                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;
            }
        }
    }

    @Override
    public Long approximateRowCntStatement(Connection connection, JdbcSourceTable table)
            throws SQLException {

        // 1. If no query is configured, use TABLE STATUS.
        // 2. If a query is configured but does not contain a WHERE clause and tablePath is
        // configured , use TABLE STATUS.
        // 3. If a query is configured with a WHERE clause, or a query statement is configured but
        // tablePath is TablePath.DEFAULT, use COUNT(*).

View on GitHub (pinned to cf67b549a7)

Solutions

  1. No fix needed if caused by intentional job cancellation; the framework expects this abort.
  2. If seen unexpectedly, check upstream for code that clears or sets interrupt status improperly (e.g. swallowing InterruptedException without restoring the flag).
  3. Reduce sampling cost (smaller table sampling window / higher samplingRate) so cancellation is fast and races are less likely.
  4. Catch InterruptedException in custom code around source enumeration and re-interrupt (Thread.currentThread().interrupt()) before retrying.

Example fix

// before
catch (InterruptedException e) {
    // swallowed
}
// after
catch (InterruptedException e) {
    Thread.currentThread().interrupt();
    throw new RuntimeException("Sampling interrupted", e);
}
Defensive patterns

Strategy: try-catch

Try / catch

try { dialect.sampleDataFromColumn(...); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new RuntimeException("Split sampling cancelled", e); }

Prevention

When it happens

Trigger: The sampling loop in sampleDataFromColumn is running and the worker thread's interrupt flag is set — typically SeaTunnel cancelling a SourceReader/task, job termination, or a caller thread being interrupted while blocking on the JDBC query.

Common situations: User cancels a running Zeta job while split enumeration is sampling a large table; checkpoint/restore timeout causes the coordinator to interrupt tasks; JVM shutdown hooks interrupt worker threads.

Related errors


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