{"record":{"id":"afbe2d54081fd584","repo":"apache/druid","slug":"query-interrupted-afbe2d","errorCode":null,"errorMessage":"Query interrupted","messagePattern":"Query interrupted","errorType":"exception","errorClass":"QueryInterruptedException","httpStatus":null,"severity":"warning","filePath":"processing/src/main/java/org/apache/druid/query/ChainedExecutionQueryRunner.java","lineNumber":170,"sourceCode":"                        }\n                    )\n                );\n\n            ListenableFuture<List<Iterable<T>>> future = Futures.allAsList(futures);\n            queryWatcher.registerQueryFuture(query, future);\n\n            try {\n              return new MergeIterable<>(\n                  context.hasTimeout() ?\n                      future.get(context.getTimeout(), TimeUnit.MILLISECONDS) :\n                      future.get(),\n                  ordering.nullsFirst()\n              ).iterator();\n            }\n            catch (CancellationException | InterruptedException e) {\n              log.noStackTrace().warn(e, \"Query interrupted, cancelling pending results for query [%s]\", query.getId());\n              GuavaUtils.cancelAll(true, future, futures);\n              throw new QueryInterruptedException(e);\n            }\n            catch (TimeoutException | QueryTimeoutException e) {\n              log.noStackTrace().warn(e, \"Query timeout, cancelling pending results for query [%s]\", query.getId());\n              GuavaUtils.cancelAll(true, future, futures);\n              throw new QueryTimeoutException(StringUtils.nonStrictFormat(\"Query [%s] timed out\", query.getId()));\n            }\n            catch (ExecutionException e) {\n              log.noStackTrace().warn(e, \"Query error, cancelling pending results for query [%s]\", query.getId());\n              GuavaUtils.cancelAll(true, future, futures);\n              Throwable cause = e.getCause();\n              // Nested per-segment future timeout\n              if (cause instanceof TimeoutException) {\n                throw new QueryTimeoutException(StringUtils.nonStrictFormat(\"Query timeout, cancelling pending results for query [%s]. Per-segment timeout exceeded.\", query.getId()));\n              }\n              Throwables.throwIfUnchecked(cause);\n              throw new RuntimeException(cause);\n            }\n          }","sourceCodeStart":152,"sourceCodeEnd":188,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/processing/src/main/java/org/apache/druid/query/ChainedExecutionQueryRunner.java#L152-L188","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\n// client\nfetch('/druid/v2', {timeout: 1000, ...}); // aborts server query\n// after\nfetch('/druid/v2', {timeout: 300000, ...}); // allow long queries to finish","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  List<Result<T>> results = queryRunner.run(query, ctx).toList();\n} catch (QueryInterruptedException e) {\n  // query was cancelled/interrupted: check client aborts or cancels\n}","preventionTips":["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"],"tags":["druid","query-cancel","interruption","timeout"],"backgroundTag":"request-timeout","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}