apache/flink · warning · IOException

Source fetch execution was interrupted

Error message

Source fetch execution was interrupted

What it means

FetchTask#run wraps an InterruptedException in an IOException with the note 'this should only happen on shutdown'. The fetch thread (running SplitReader#fetch or the queue put) was interrupted, which is the normal cancellation/cleanup path, but it is surfaced as an exception so the SplitFetcher records it.

Source

Thrown at flink-connectors/flink-connector-base/src/main/java/org/apache/flink/connector/base/source/reader/fetcher/FetchTask.java:74

        try {
            if (!isWakenUp() && lastRecords == null) {
                lastRecords = splitReader.fetch();
            }

            if (!isWakenUp()) {
                // The order matters here. We must first put the last records into the queue.
                // This ensures the handling of the fetched records is atomic to wakeup.
                if (elementsQueue.put(fetcherIndex, lastRecords)) {
                    if (!lastRecords.finishedSplits().isEmpty()) {
                        // The callback does not throw InterruptedException.
                        splitFinishedCallback.accept(lastRecords.finishedSplits());
                    }
                    lastRecords = null;
                }
            }
        } catch (InterruptedException e) {
            // this should only happen on shutdown
            throw new IOException("Source fetch execution was interrupted", e);
        } finally {
            // clean up the potential wakeup effect. It is possible that the fetcher is waken up
            // after the clean up. In that case, either the wakeup flag will be set or the
            // running thread will be interrupted. The next invocation of run() will see that and
            // just skip.
            if (isWakenUp()) {
                wakeup = false;
            }
        }
        // The return value of fetch task does not matter.
        return true;
    }

    @Override
    public void wakeUp() {
        // Set the wakeup flag first.
        wakeup = true;
        if (lastRecords == null) {

View on GitHub (pinned to 2f3c205e92)

Solutions

  1. Treat this as expected during cancellation/close; if seen during normal operation, investigate who interrupted the fetch thread.
  2. Ensure you are not calling Thread#interrupt on the SplitFetcher thread from user code or a misbehaving SplitReader.
  3. If it recurs outside shutdown, verify the SplitReader handles interruptions cleanly rather than propagating them.
  4. Check that the source is not being closed with too short a timeout that forces interruption.
Defensive patterns

Strategy: try-catch

Try / catch

// Framework-level: this is expected during shutdown. In a custom SplitReader:
public RecordsWithSplitIds<E> fetch() throws IOException {
    try {
        return splitReader.fetch();
    } catch (IOException e) {
        if (Thread.currentThread().isInterrupted() && e.getMessage().contains("interrupted")) {
            // shutdown path; stop gracefully
            return null;
        }
        throw e;
    }
}

Prevention

When it happens

Trigger: The SplitFetcher thread is interrupted during splitReader.fetch() or during elementsQueue.put(...). Happens during source close, task cancellation, or failover when the framework interrupts the fetcher to stop it.

Common situations: Job cancellation while a fetch is in progress; source close timeout triggering thread interruption; failover of the task. Generally expected and benign during shutdown.

Related errors


AI-assisted analysis of apache/flink@2f3c205e92 (2026-08-14). Data as JSON: /api/errors/ca654dce9ffea6d9. Report an issue: GitHub.