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

  1. Verify this occurred during shutdown/cancellation — if so it is expected and benign; check job shutdown logs
  2. If unexpected, audit code that interrupts the fetcher thread (executor.shutdownNow, custom cancel logic)
  3. Ensure shutdown() uses wakeUp/shutdownRequested signaling instead of raw interrupt to stop idle fetchers
  4. 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

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


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