{"record":{"id":"2eaef8961170474e","repo":"apache/druid","slug":"query-s-timed-out-2eaef8","errorCode":null,"errorMessage":"Query[%s] timed out.","messagePattern":"Query\\[(.+?)\\] timed out\\.","errorType":"exception","errorClass":"RE","httpStatus":null,"severity":"error","filePath":"server/src/main/java/org/apache/druid/discovery/DataServerResponseHandler.java","lineNumber":127,"sourceCode":"            {\n              throw e;\n            }\n          }\n      );\n    }\n    catch (InterruptedException e) {\n      Thread.currentThread().interrupt();\n      throw new RuntimeException(e);\n    }\n    return ClientResponse.finished(\n        new SequenceInputStream(\n            new Enumeration<>()\n            {\n              @Override\n              public boolean hasMoreElements()\n              {\n                if (fail.get() != null) {\n                  throw new RE(fail.get());\n                }\n                checkQueryTimeout();\n\n                // Done is always true until the last stream has be put in the queue.\n                // Then the stream should be spouting good InputStreams.\n                synchronized (done) {\n                  return !done.get() || !queue.isEmpty();\n                }\n              }\n\n              @Override\n              public InputStream nextElement()\n              {\n                if (fail.get() != null) {\n                  throw new RE(fail.get());\n                }\n\n                try {","sourceCodeStart":109,"sourceCodeEnd":145,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/server/src/main/java/org/apache/druid/discovery/DataServerResponseHandler.java#L109-L145","documentation":"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.\").","triggerScenarios":"Iterating results of a native query whose data-server response takes longer than the query timeout; the deadline is checked on every hasMoreElements() call.","commonSituations":"Slow segment loads on historicals, overloaded data servers, overly strict timeout budget for large scans.","solutions":["Increase the query timeout in the query context (or maxTimeout config)","Check data-server health and segment load times causing the delay","Catch QueryTimeoutException and retry with a larger timeout or narrower query scope"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  while (results.hasMoreElements()) { /* consume */ }\n} catch (QueryTimeoutException e) {\n  log.warn(\"query timed out; resubmitting with larger budget\");\n  // resubmit with increased timeout\n}","preventionTips":["Set realistic query timeouts based on data volume","Monitor data-server latency and segment load times","Avoid large scans under very small timeout budgets"],"tags":["timeout","query","distributed"],"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"}