apache/druid · error · RuntimeException
Failed to load initial batch of results
Error message
Failed to load initial batch of results
What it means
In ParallelMergeCombiningSequence's yielder initialization, ForkJoinPool.managedBlock() waits for the first ResultBatch from a merge-combine worker. An InterruptedException while waiting is wrapped in a RuntimeException('Failed to load initial batch of results'), after marking the batchYielder done so resources are released.
Source
Thrown at processing/src/main/java/org/apache/druid/java/util/common/guava/ParallelMergeCombiningSequence.java:977
private final int batchSize;
private volatile Yielder<ResultBatch<E>> batchYielder;
SequenceBatcher(Sequence<E> sequence, int batchSize)
{
this.sequence = sequence;
this.batchSize = batchSize;
}
Yielder<ResultBatch<E>> getBatchYielder()
{
try {
batchYielder = null;
ForkJoinPool.managedBlock(this);
return batchYielder;
}
catch (InterruptedException e) {
batchYielder = Yielders.done(null, null);
throw new RuntimeException("Failed to load initial batch of results", e);
}
}
@Override
public boolean block()
{
batchYielder = ResultBatch.fromSequence(sequence, batchSize);
return true;
}
@Override
public boolean isReleasable()
{
return batchYielder != null;
}
}
/**View on GitHub (pinned to 9b90983fd2)
Solutions
- Check the InterruptedException cause to identify the canceller (timeout vs explicit cancel)
- Re-issue the query if it was cancelled transiently; otherwise fix the timeout/cancellation configuration
- Ensure worker queues are healthy — slow producers make the initial batch wait long and vulnerable to cancellation
Example fix
// before
Yielder<...> y = seq.toYielder(init, acc); // interrupted
// after
try {
Yielder<...> y = seq.toYielder(init, acc);
} catch (RuntimeException e) {
if (e.getMessage().contains("Failed to load initial batch") && e.getCause() instanceof InterruptedException) {
// handle cancellation explicitly
}
throw e;
} Defensive patterns
Strategy: try-catch
Try / catch
try { yielder = seq.toYielder(init, acc); } catch (RuntimeException e) {
if ("Failed to load initial batch of results".equals(e.getMessage()) && e.getCause() instanceof InterruptedException) { Thread.currentThread().interrupt(); }
else throw e;
} Prevention
- Set sane query timeouts so merges finish before cancellation
- Ensure parallel merge workers are not starved (adequate merge buffers/threads)
- Restore the interrupt flag when catching to preserve cancellation semantics
When it happens
Trigger: Thread interruption while the combining thread blocks waiting for the first batch of results from the parallel merge workers (e.g. during ParallelMergeCombiningSequence.toYielder).
Common situations: Query cancellation via QueryScheduler/timeout, broker cancellation endpoint, or server shutdown during the initial phase of a parallel merge combining sequence.
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
- Failed to offer result to output queue
- Failed to load next batch of results
- Exception while waiting to extract distributions.
- Query interrupted
- Emit called unexpectedly before service start
AI-assisted analysis of apache/druid@9b90983fd2 (2026-09-07).
Data as JSON: /api/errors/72b209125a65cf56.
Report an issue: GitHub.