apache/seatunnel · warning · InterruptedException

Thread interrupted

Error message

Thread interrupted

What it means

SqlServerUtils.skipReadAndSortSampleData samples split-column values (skipping rows and taking every Nth) and explicitly throws InterruptedException with message 'Thread interrupted' when the current thread's interrupt flag is set mid-iteration. This is cooperative cancellation of the sampling query so the task can stop promptly.

Source

Thrown at seatunnel-connectors-v2/connector-cdc/connector-cdc-sqlserver/src/main/java/org/apache/seatunnel/connectors/seatunnel/cdc/sqlserver/utils/SqlServerUtils.java:183

            stmt =
                    jdbc.connection()
                            .createStatement(
                                    ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);

            stmt.setFetchSize(1024);
            rs = stmt.executeQuery(sampleQuery);

            int count = 0;
            while (rs.next()) {
                count++;
                if (count % 100000 == 0) {
                    log.info("Processing row index: {}", count);
                }
                if (count % inverseSamplingRate == 0) {
                    results.add(rs.getObject(1));
                }
                if (Thread.currentThread().isInterrupted()) {
                    throw new InterruptedException("Thread interrupted");
                }
            }
        } finally {
            if (rs != null) {
                try {
                    rs.close();
                } catch (SQLException e) {
                    log.error("Failed to close ResultSet", e);
                }
            }
            if (stmt != null) {
                try {
                    stmt.close();
                } catch (SQLException e) {
                    log.error("Failed to close Statement", e);
                }
            }
        }

View on GitHub (pinned to cf67b549a7)

Solutions

  1. Expected during cancellation — no fix needed; the interruption propagates so the task can shut down cleanly
  2. If unexpected, check worker logs for job cancel/restart events just before the error
  3. Reduce sampling cost on very large tables (raise inverse-sampling-rate / split size) so interruption windows are shorter
  4. Ensure the engine's shutdown/restore flow is not spuriously interrupting healthy tasks (check engine version)
Defensive patterns

Strategy: try-catch

Validate before calling

// Check the thread interrupt flag before/inside long sampling loops
if (Thread.currentThread().isInterrupted()) {
    throw new InterruptedException("Aborting sample before query");
}

Try / catch

try {
    skipReadAndSortSampleData(...);
} catch (InterruptedException ie) {
    Thread.currentThread().interrupt(); // restore flag
    log.info("Sampling cancelled, shutting down reader");
    return; // clean exit
}

Prevention

When it happens

Trigger: Thread.interrupt() called on the reader thread while the sampling ResultSet loop is iterating — job cancellation by the engine, task restart, or shutdown hook during skipReadAndSortSampleData.

Common situations: User cancels or fails the job while the snapshot is sampling data; engine restarts the source reader (e.g. checkpoint/restore); container/pod shutdown; long sampling query on a huge table gets interrupted.

Related errors


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