apache/seatunnel · warning · InterruptedException

Thread interrupted

Error message

Thread interrupted

What it means

OracleDialect.sampleDataFromColumn samples column values by iterating a ResultSet and throws InterruptedException if the worker thread is interrupted mid-sampling. This honors cooperative cancellation so long-running sampling queries can be aborted promptly instead of blocking. The interruption check runs every row inside the rs.next() loop.

Source

Thrown at seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/oracle/OracleDialect.java:363

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

        try (PreparedStatement stmt = creatPreparedStatement(connection, sampleQuery, fetchSize)) {
            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;
            }
        }
    }

    @Override
    public void applySchemaChange(
            Connection connection, TablePath tablePath, AlterTableAddColumnEvent event)
            throws SQLException {
        List<String> ddlSQL = new ArrayList<>();
        ddlSQL.add(buildUpdateColumnSQL(connection, tablePath, event));

        if (event.getColumn().getComment() != null) {
            ddlSQL.add(buildUpdateColumnCommentSQL(tablePath, event.getColumn()));

View on GitHub (pinned to cf67b549a7)

Solutions

  1. Treat it as expected cancellation: catch InterruptedException, restore the interrupt flag (Thread.currentThread().interrupt()), and abort the split enumeration cleanly
  2. Investigate why the thread was interrupted (job cancelled, worker shutdown, checkpoint timeout) if cancellation was not intended
  3. Reduce sampling cost (raise samplingRate or limit the query) so sampling finishes quickly and is less likely to be interrupted
  4. Ensure connection/statement resources are closed in finally/try-with-resources when propagating the exception

Example fix

// before
try {
    Object[] sample = dialect.sampleDataFromColumn(conn, table, column, samplingRate);
} catch (InterruptedException e) {
    // swallowed, lost cancellation signal
}
// after
try {
    Object[] sample = dialect.sampleDataFromColumn(conn, table, column, samplingRate);
} catch (InterruptedException e) {
    Thread.currentThread().interrupt();
    throw new RuntimeException("Sampling cancelled for column " + column, e);
}
Defensive patterns

Strategy: try-catch

Try / catch

try {
    dialect.sampleDataFromColumn(conn, table, column, rate);
} catch (InterruptedException e) {
    Thread.currentThread().interrupt();
    throw new CancellationException("Column sampling interrupted");
}

Prevention

When it happens

Trigger: The task thread executing sampleDataFromColumn is interrupted (job cancel, checkpoint timeout kill, shutdown) while the sampling ResultSet is being iterated.

Common situations: User cancels a running SeaTunnel job; engine shuts down workers during a large-table split enumeration; upstream cancellation propagates to the thread blocked on a slow Oracle sampling query.

Related errors


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