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
- Treat as expected during cancellation/shutdown; the interrupt flag is preserved so upstream cleanup proceeds.
- If observed during steady-state, find what is interrupting the SplitFetcher thread outside the normal close path.
- 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
- Do not call addSplits or wakeUp on a SplitFetcher after shutdown().
- Let the framework manage fetcher lifecycle; avoid manual thread interruption.
- Distinguish teardown interruptions from steady-state failures in error handling.
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
- Source fetch execution was interrupted
- SplitFetcher thread %d received unexpected exception while p
- One or more fetchers have encountered exception
- This split reader does not support pausing or resuming split
- exception in queue future completion
AI-assisted analysis of apache/flink@2f3c205e92 (2026-08-14).
Data as JSON: /api/errors/8686d817b30b6859.
Report an issue: GitHub.