apache/flink · warning · RuntimeException

The thread was interrupted while waiting for a fetcher task.

Error message

The thread was interrupted while waiting for a fetcher task.

What it means

While waiting for the next task (getNextTaskUnsafe), the SplitFetcher thread's Condition.await was interrupted. The code re-sets the interrupt flag (Thread.currentThread().interrupt()) and throws a RuntimeException. This signals the fetcher is being torn down.

Source

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

                resumed.await();
                // if it was paused, ensure that fetcher was not shutdown
                return null;
            }
            if (!taskQueue.isEmpty()) {
                // a specific task is avail, so take that in FIFO
                return taskQueue.poll();
            } else if (!assignedSplits.isEmpty()) {
                // use fallback task = fetch if there is at least one split
                return fetchTask;
            } else {
                // nothing to do, wait for signal
                nonEmpty.await();
                return taskQueue.poll();
            }
        } catch (InterruptedException e) {
            Thread.currentThread().interrupt();

            throw new RuntimeException(
                    "The thread was interrupted while waiting for a fetcher task.");
        }
    }

    /**
     * Add splits to the split fetcher. This operation is asynchronous.
     *
     * @param splitsToAdd the splits to add.
     */
    public void addSplits(List<SplitT> splitsToAdd) {
        lock.lock();
        try {
            enqueueTaskUnsafe(new AddSplitsTask<>(splitReader, splitsToAdd, assignedSplits));
            wakeUpUnsafe(true);
        } finally {
            lock.unlock();
        }
    }

View on GitHub (pinned to 2f3c205e92)

Solutions

  1. Treat as expected during cancellation/shutdown; the interrupt flag is preserved so upstream cleanup proceeds.
  2. If observed during steady-state, find what is interrupting the SplitFetcher thread outside the normal close path.
  3. Avoid calling SplitFetcher methods after shutdown to prevent spurious interrupts.
Defensive patterns

Strategy: try-catch

Try / catch

// Expected during shutdown; only act if seen outside teardown:
try {
    splitFetcher.run();
} catch (RuntimeException e) {
    if (e.getMessage().contains("interrupted while waiting for a fetcher task")
            && isShuttingDown) {
        return; // benign
    }
    throw e;
}

Prevention

When it happens

Trigger: SplitFetcher is shutdown/cancelled while it is idle and blocked on the nonEmpty condition waiting for tasks. Triggered by source close, task cancellation, or failover.

Common situations: Job cancellation while the fetcher is idle; source shutdown; failover. Expected during teardown.

Related errors


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