apache/druid · warning · RejectedExecutionException
Got Interrupted while adding to the Queue
Error message
Got Interrupted while adding to the Queue
What it means
The same custom RejectedExecutionHandler in Execs attempts executor.getQueue().put(r) when the executor is running; if the inserting thread is interrupted while blocked on a full queue, it wraps the InterruptedException in RejectedExecutionException('Got Interrupted while adding to the Queue'). The original interrupt status is carried as the cause.
Solutions
- Increase the executor's queue capacity or add more worker threads so put() rarely blocks
- Restore the interrupt status in your caller (Thread.currentThread().interrupt()) if you catch and swallow this exception upstream
- Check whether the submitting thread is being interrupted too aggressively (over-eager cancellation/timeouts)
- Use offer() with timeout or CallerRunsPolicy-style backpressure instead of indefinite blocking put
Example fix
// before
exec.submit(task); // may throw RejectedExecutionException(cause=InterruptedException)
// after
try {
exec.submit(task);
} catch (RejectedExecutionException e) {
if (e.getCause() instanceof InterruptedException) {
Thread.currentThread().interrupt();
}
throw e;
} Defensive patterns
Strategy: try-catch
Validate before calling
// avoid blocking put on a full queue
boolean accepted = executor.getQueue().offer(task);
if (!accepted) { /* apply backpressure or reject explicitly */ } Try / catch
try {
executor.submit(task);
} catch (RejectedExecutionException e) {
if (e.getCause() instanceof InterruptedException) {
Thread.currentThread().interrupt(); // preserve interrupt status
}
throw e;
} Prevention
- Size bounded queues and thread pools for peak producer rates
- Avoid interrupting submitter threads except for genuine cancellation
- Monitor queue depth/offer latency and alert before saturation
- Prefer offer-with-timeout policies over indefinite blocking puts
When it happens
Trigger: Submitting a task to a bounded ThreadPoolExecutor whose queue is full, where the calling thread is interrupted while blocked in put() waiting for queue space.
Common situations: Overloaded executors with small bounded queues and fast producers; task-submitter threads cancelled/interrupted during shutdown or timeout; caller thread's interrupt flag set by an enclosing timeout mechanism.
Understand the failure class
Background: Request timed out: what client-side request timeouts mean across libraries (Request timed out, TIMED_OUT, APITimeoutError) — this error's family across 39 libraries.
Related errors
- Executor already shutdown
- Executor is shutdown, rejecting task
- Attempt to add row to swapped-out sink for segment
- Background lookup manager thread could not be cancelled
- can't start.
AI-assisted analysis of apache/druid@9b90983fd2 (2026-09-07).
Data as JSON: /api/errors/47b6a2e829ed104b.
Report an issue: GitHub.
Appendix: source
Thrown at processing/src/main/java/org/apache/druid/java/util/common/concurrent/Execs.java:169
nThreads,
nThreads,
0L,
TimeUnit.MILLISECONDS,
queue,
makeThreadFactory(nameFormat, priority),
new RejectedExecutionHandler()
{
@Override
public void rejectedExecution(Runnable r, ThreadPoolExecutor executor)
{
if (executor.isShutdown()) {
throw new RejectedExecutionException("Executor is shutdown, rejecting task");
}
try {
executor.getQueue().put(r);
}
catch (InterruptedException e) {
throw new RejectedExecutionException("Got Interrupted while adding to the Queue", e);
}
}
}
);
}
public static ListeningExecutorService directExecutor()
{
return new DirectExecutorService();
}
}
View on GitHub (pinned to 9b90983fd2)