apache/druid · warning · QueryInterruptedException
Query interrupted
Error message
Query interrupted
What it means
Wraps CancellationException or InterruptedException from waiting on per-segment futures in ChainedExecutionQueryRunner.make() into a QueryInterruptedException with message "Query interrupted". It means the query was cancelled (client disconnect, explicit cancel, or shutdown) while the chain of segment results was being collected, and pending result futures are cancelled.
Source
Thrown at processing/src/main/java/org/apache/druid/query/ChainedExecutionQueryRunner.java:170
}
)
);
ListenableFuture<List<Iterable<T>>> future = Futures.allAsList(futures);
queryWatcher.registerQueryFuture(query, future);
try {
return new MergeIterable<>(
context.hasTimeout() ?
future.get(context.getTimeout(), TimeUnit.MILLISECONDS) :
future.get(),
ordering.nullsFirst()
).iterator();
}
catch (CancellationException | InterruptedException e) {
log.noStackTrace().warn(e, "Query interrupted, cancelling pending results for query [%s]", query.getId());
GuavaUtils.cancelAll(true, future, futures);
throw new QueryInterruptedException(e);
}
catch (TimeoutException | QueryTimeoutException e) {
log.noStackTrace().warn(e, "Query timeout, cancelling pending results for query [%s]", query.getId());
GuavaUtils.cancelAll(true, future, futures);
throw new QueryTimeoutException(StringUtils.nonStrictFormat("Query [%s] timed out", query.getId()));
}
catch (ExecutionException e) {
log.noStackTrace().warn(e, "Query error, cancelling pending results for query [%s]", query.getId());
GuavaUtils.cancelAll(true, future, futures);
Throwable cause = e.getCause();
// Nested per-segment future timeout
if (cause instanceof TimeoutException) {
throw new QueryTimeoutException(StringUtils.nonStrictFormat("Query timeout, cancelling pending results for query [%s]. Per-segment timeout exceeded.", query.getId()));
}
Throwables.throwIfUnchecked(cause);
throw new RuntimeException(cause);
}
}View on GitHub (pinned to 9b90983fd2)
Solutions
- Increase client-side (HTTP/dashboard) timeouts so queries are not aborted prematurely
- Tune query timeouts: set context timeout or druid.server.http.numThreads / query scheduler settings appropriately
- Check logs for who cancelled the query (QueryInterruptedException + 'Query interrupted') and coordinate with clients issuing cancels
- Retry the query if cancellation was due to infra restart; ensure graceful shutdown drains queries
Example fix
// before
// client
fetch('/druid/v2', {timeout: 1000, ...}); // aborts server query
// after
fetch('/druid/v2', {timeout: 300000, ...}); // allow long queries to finish Defensive patterns
Strategy: try-catch
Try / catch
try {
List<Result<T>> results = queryRunner.run(query, ctx).toList();
} catch (QueryInterruptedException e) {
// query was cancelled/interrupted: check client aborts or cancels
} Prevention
- Set client HTTP timeouts longer than expected query duration
- Avoid hard-cancelling queries from dashboards/BI tools on short timeouts
- Enable graceful shutdown on brokers/historicals to drain in-flight queries
- Monitor cancel events via query metrics to find offending clients
When it happens
Trigger: Client closes the HTTP connection mid-query; another thread cancels the query future (druid query cancellation endpoint or broker timeout handling); JVM shutdown interrupts query threads; QueryInterruptedException propagated as a wrapped future failure causing cancellation.
Common situations: Dashboard or BI tool request timeouts that abort the HTTP request server-side; users hitting the /druid/v2/{id} cancel endpoint; broker or historical restart during long queries; overly aggressive downstream HTTP client timeouts.
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
- Exception while waiting to extract distributions.
- Resume command was not accepted within 5 seconds
- Failed to offer result to output queue
- Failed to load initial batch of results
- Failed to load next batch of results
AI-assisted analysis of apache/druid@9b90983fd2 (2026-09-07).
Data as JSON: /api/errors/afbe2d54081fd584.
Report an issue: GitHub.