{"record":{"id":"fe11f76e0eb27bb0","repo":"prestodb/presto","slug":"query-aborted-by-user","errorCode":null,"errorMessage":"Query aborted by user","messagePattern":"Query aborted by user","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"info","filePath":"presto-plan-checker-router-plugin/src/main/java/com/facebook/presto/router/scheduler/PlanCheckerRouterPluginPrestoClient.java","lineNumber":100,"sourceCode":"    public Optional<URI> getCompatibleClusterURI(Map<String, List<String>> headers, String statement, Principal principal)\n    {\n        String newSql = ANALYZE_CALL + statement;\n        ClientSession clientSession = parseHeadersToClientSession(headers, principal, getPlanCheckerClusterDestination());\n        boolean isNativeCompatible = true;\n        // submit initial query\n        try (StatementClient client = newStatementClient(httpClient, clientSession, newSql)) {\n            // read query output\n            while (client.isRunning()) {\n                log.debug((client.currentData().toString()));\n\n                if (!client.advance()) {\n                    break;\n                }\n            }\n\n            // verify final state\n            if (client.isClientAborted()) {\n                throw new IllegalStateException(\"Query aborted by user\");\n            }\n\n            if (client.isClientError()) {\n                throw new IllegalStateException(\"Query is gone (server restarted?)\");\n            }\n\n            verify(client.isFinished());\n            QueryError resultsError = client.finalStatusInfo().getError();\n            if (resultsError != null) {\n                isNativeCompatible = false;\n                log.info(resultsError.getMessage());\n            }\n        }\n        catch (Exception e) {\n            if (javaClusterFallbackEnabled) {\n                // If any exception is thrown, log the message and re-route to a Java clusters router.\n                isNativeCompatible = false;\n                log.info(e.getMessage());","sourceCodeStart":82,"sourceCodeEnd":118,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-plan-checker-router-plugin/src/main/java/com/facebook/presto/router/scheduler/PlanCheckerRouterPluginPrestoClient.java#L82-L118","documentation":"In PlanCheckerRouterPluginPrestoClient.getCompatibleClusterURI, after the request loop finishes, the code checks whether the underlying Presto client was aborted by the user; if so it throws IllegalStateException('Query aborted by user'). This signals the routing/request cycle ended because the caller (or its cancellation) aborted the query, not because of a server-side failure.","triggerScenarios":"The caller cancels/closes the client (isClientAborted()) while the plugin is polling clusters for a compatible one — e.g. a user cancels the query in their client or the upstream statement client is closed mid-routing.","commonSituations":"User hits Ctrl-C or client timeout, application shuts down a query in flight, driver-level cancellation propagating to the plan-checker router client.","solutions":["This is an expected cancellation path: handle/catch it as user cancellation rather than retrying","If unexpected, audit the caller for premature close()/cancel() of the statement client","Increase client timeouts if aggressive deadlines are aborting requests before a cluster is found"],"exampleFix":"// before\nURI uri = client.getCompatibleClusterURI(...); // may throw\n// after\ntry { uri = client.getCompatibleClusterURI(...); }\ncatch (IllegalStateException e) { if (!e.getMessage().contains(\"aborted by user\")) throw e; /* treat as cancellation */ }","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { uri = client.getCompatibleClusterURI(request); }\ncatch (IllegalStateException e) {\n    if (\"Query aborted by user\".equals(e.getMessage())) { markCancelled(); return; }\n    throw e;\n}","preventionTips":["Treat this as normal cancellation flow, not a server error","Avoid closing/cancelling the client mid-routing unless intended","Set realistic timeouts so deadlines do not silently abort in-flight routing requests"],"tags":["cancellation","query-abort","presto-router"],"backgroundTag":"query-cancelled-by-user","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}