{"record":{"id":"ec1d6a8b53c44641","repo":"apache/druid","slug":"query-error-cancelling-pending-results-for-query-ec1d6a","errorCode":null,"errorMessage":"Query error, cancelling pending results for query [%s]","messagePattern":"Query error, cancelling pending results for query \\[(.+?)\\]","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"processing/src/main/java/org/apache/druid/query/groupby/epinephelinae/GroupByMergingQueryRunner.java","lineNumber":402,"sourceCode":"      for (AggregateResult result : results) {\n        if (!result.isOk()) {\n          GuavaUtils.cancelAll(true, future, futures);\n          throw new ResourceLimitExceededException(result.getReason());\n        }\n      }\n    }\n    catch (InterruptedException | CancellationException 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 (QueryTimeoutException | TimeoutException 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      throw new RuntimeException(e);\n    }\n  }\n}\n","sourceCodeStart":384,"sourceCodeEnd":413,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/processing/src/main/java/org/apache/druid/query/groupby/epinephelinae/GroupByMergingQueryRunner.java#L384-L413","documentation":"GroupByMergingQueryRunner logs this warning when a pending per-segment future completes exceptionally while merging group-by results from data nodes. The runner cancels all outstanding futures and rethrows the cause as a QueryException (QueryTimeoutException for timeouts). It indicates a per-segment query failed on a historical server while the merge was waiting for results.","triggerScenarios":"A per-segment future passed to waitForFutureCompletion completes with an ExecutionException, e.g. a segment-level query threw on a historical node, or a nested per-segment future timed out (TimeoutException cause).","commonSituations":"Historical nodes failing on segment processing (OOM, corrupt segment, bad query on one segment), per-segment timeouts configured too low, network failures between broker and historials during a group-by merge.","solutions":["Inspect the underlying cause in the logged exception to find which segment/node failed","Check historical node logs for the per-segment failure (OOM, segment corruption)","Raise query timeout / per-segment timeout if the cause was a TimeoutException","Retry the query; if a specific segment is corrupt, re-index or drop it"],"exampleFix":"// before: default per-segment timeout too small for heavy scans\n// druid.query.groupBy.timeout=30000\n// after: increase broker timeout config\n// druid.query.timeout=300000; verify historical logs for segment-level failures","handlingStrategy":"try-catch","validationCode":"// No pre-call validation available; ensure timeouts configured\n// druid.query.timeout and per-segment timeouts set generously before issuing group-by queries","typeGuard":"null","tryCatchPattern":"try { runner.run(...) } catch (QueryTimeoutException e) { /* retry with larger timeout / narrower interval */ } catch (QueryException e) { log.error(\"cause\", e.getCause()); }","preventionTips":["Set broker query timeout and per-segment timeouts appropriately for data volume","Monitor historical node logs for per-segment failures (OOM, corrupt segments)","Keep historical nodes healthy; retry on node restarts"],"tags":["query","timeout","groupby","merge"],"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"}