apache/seatunnel · error · 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
getNextTaskUnsafe waits on the task queue's condition (nonEmpty.await()) when no task is queued. If the waiting thread is interrupted, it re-interrupts itself and throws this RuntimeException so the fetcher run loop terminates deliberately rather than silently resuming with a possibly empty poll().
Source
Thrown at seatunnel-connectors-v2/connector-common/src/main/java/org/apache/seatunnel/connectors/seatunnel/common/source/reader/fetcher/SplitFetcher.java:203
"Unsafe invoke, the current thread[%s] has not acquired the lock[%s].",
Thread.currentThread().getName(), this.lock.toString()));
}
try {
if (!taskQueue.isEmpty()) {
// execute tasks in taskQueue first
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.");
}
}
private void wakeUpUnsafe(boolean taskOnly) {
if (!lock.isHeldByCurrentThread()) {
throw new RuntimeException(
String.format(
"Unsafe invoke, the current thread[%s] has not acquired the lock[%s].",
Thread.currentThread().getName(), this.lock.toString()));
}
SplitFetcherTask currentTask = runningTask;
if (currentTask != null) {
log.debug("Waking up running task {}", currentTask);
currentTask.wakeUp();
} else if (!taskOnly) {
log.debug("Waking up fetcher thread.");View on GitHub (pinned to cf67b549a7)
Solutions
- Verify this occurred during shutdown/cancellation — if so it is expected and benign; check job shutdown logs
- If unexpected, audit code that interrupts the fetcher thread (executor.shutdownNow, custom cancel logic)
- Ensure shutdown() uses wakeUp/shutdownRequested signaling instead of raw interrupt to stop idle fetchers
- Check for races where SplitFetcherManager.close() runs while splits are still being added — order shutdown after split assignment
Defensive patterns
Strategy: try-catch
Validate before calling
// check shutdown state before interpreting interruption
if (splitFetcherManager.isClosed()) {
LOG.info("fetcher interrupted as part of shutdown; expected");
} Try / catch
try {
reader.pollNext(...);
} catch (RuntimeException e) {
if ("The thread was interrupted while waiting for a fetcher task.".equals(e.getMessage())
&& shuttingDown.get()) {
LOG.info("benign interrupt during shutdown");
return;
}
throw e;
} Prevention
- Use wakeUp()/shutdown signaling rather than raw thread.interrupt() to stop fetchers
- Order shutdown before returning from source reader close to avoid idle-wait interrupts
- Avoid executor.shutdownNow() on fetcher executors while splits are pending
- Treat this error as expected during cancellation; alert only when it appears in steady-state runs
When it happens
Trigger: The fetcher thread blocked in nonEmpty.await() inside getNextTaskUnsafe receives Thread.interrupt() — normally during shutdownRequested handling, cancellation, or when another thread calls interrupt() on the fetcher thread.
Common situations: Job cancellation while the fetcher idles waiting for splits; executor shutdownNow() interrupting fetcher threads; race where shutdown happens before a task is enqueued; test code interrupting threads.
Related errors
- Source fetch execution was fail
- Unsafe invoke, the current thread[%s] has not acquired the l
- Interrupted during edge transport open
- Thread interrupted
- Interrupted while emitting initial DROP TABLE events
AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10).
Data as JSON: /api/errors/9ab335f968c59606.
Report an issue: GitHub.