{"record":{"id":"ae6cf1e988e1d2bd","repo":"apache/druid","slug":"failed-to-cancel-query-s-on-server-s","errorCode":null,"errorMessage":"Failed to cancel query[%s] on server[%s]","messagePattern":"Failed to cancel query\\[(.+?)\\] on server\\[(.+?)\\]","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"server/src/main/java/org/apache/druid/discovery/DataServerClient.java","lineNumber":188,"sourceCode":"        new RequestBuilder(HttpMethod.DELETE, cancelPath).timeout(CANCELLATION_TIMEOUT),\n        IgnoreHttpResponseHandler.INSTANCE\n    );\n\n    Futures.addCallback(\n        cancelFuture,\n        new FutureCallback<>()\n        {\n          @Override\n          public void onSuccess(final Void result)\n          {\n            // Do nothing on successful cancellation.\n          }\n\n          @Override\n          public void onFailure(final Throwable t)\n          {\n            log.noStackTrace()\n               .warn(t, \"Failed to cancel query[%s] on server[%s]\", queryId, serviceLocation.getHostAndPort());\n          }\n        },\n        Execs.directExecutor()\n    );\n  }\n}\n","sourceCodeStart":170,"sourceCodeEnd":195,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/server/src/main/java/org/apache/druid/discovery/DataServerClient.java#L170-L195","documentation":"Log warning in DataServerClient when the asynchronous HTTP call to cancel a query on a data server (historical/peon) fails. The client fires cancel requests to every server hosting the query; failure to cancel on one server is logged with the cause but does not affect the cancel result returned to the caller.","triggerScenarios":"QueryResource.cancel POST to /druid/v2/{id} on a server returns an error or the FutureCallback's onFailure fires: server down, connection reset, query already completed on that server, or HTTP 4xx/5xx from the broker/data node.","commonSituations":"User cancels a query that has just finished on some servers; historical is restarting or unreachable; network partition between broker and data server; cancellation storm overloading data nodes.","solutions":["Check the embedded throwable to see if the server is down (connection refused) or returned an HTTP error.","Verify the target server is healthy and reachable (its /status endpoint).","Treat as benign if the query already completed — cancellation of finished queries commonly fails this way.","If persistent, check data server logs for the query id and inspect httpClient settings (readTimeout, numConnections) in druid.http config."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Pre-check server health before issuing cancel\nboolean healthy = httpClient.get(serverUrl + \"/status/health\").isSuccess();","typeGuard":null,"tryCatchPattern":"future.cancel().addListener(() -> {\n  try { future.get(); }\n  catch (ExecutionException e) {\n    log.warn(\"Cancel on %s failed (may be benign if query finished): %s\", location, e.getCause());\n  }\n});","preventionTips":["Treat single-server cancel failures as benign when the query already completed","Monitor data-server availability; most failures are dead/restarting historicals","Check data node logs by query id when failures are persistent"],"tags":["http","query-cancellation","distributed"],"backgroundTag":"http-request-failed","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}