apache/druid · error · RE

Query[%s] timed out.

Error message

Query[%s] timed out.

What it means

DataServerResponseHandler's anonymous Enumeration.hasMoreElements() first rethrows any recorded failure as RE, then calls checkQueryTimeout(). If the query deadline (failTime) elapsed while waiting for data-server chunks, it throws QueryTimeoutException("Query[%s] timed out.").

Source

Thrown at server/src/main/java/org/apache/druid/discovery/DataServerResponseHandler.java:127

            {
              throw e;
            }
          }
      );
    }
    catch (InterruptedException e) {
      Thread.currentThread().interrupt();
      throw new RuntimeException(e);
    }
    return ClientResponse.finished(
        new SequenceInputStream(
            new Enumeration<>()
            {
              @Override
              public boolean hasMoreElements()
              {
                if (fail.get() != null) {
                  throw new RE(fail.get());
                }
                checkQueryTimeout();

                // Done is always true until the last stream has be put in the queue.
                // Then the stream should be spouting good InputStreams.
                synchronized (done) {
                  return !done.get() || !queue.isEmpty();
                }
              }

              @Override
              public InputStream nextElement()
              {
                if (fail.get() != null) {
                  throw new RE(fail.get());
                }

                try {

View on GitHub (pinned to 9b90983fd2)

Solutions

  1. Increase the query timeout in the query context (or maxTimeout config)
  2. Check data-server health and segment load times causing the delay
  3. Catch QueryTimeoutException and retry with a larger timeout or narrower query scope
Defensive patterns

Strategy: try-catch

Try / catch

try {
  while (results.hasMoreElements()) { /* consume */ }
} catch (QueryTimeoutException e) {
  log.warn("query timed out; resubmitting with larger budget");
  // resubmit with increased timeout
}

Prevention

When it happens

Trigger: Iterating results of a native query whose data-server response takes longer than the query timeout; the deadline is checked on every hasMoreElements() call.

Common situations: Slow segment loads on historicals, overloaded data servers, overly strict timeout budget for large scans.

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


AI-assisted analysis of apache/druid@9b90983fd2 (2026-09-07). Data as JSON: /api/errors/2eaef8961170474e. Report an issue: GitHub.