prestodb/presto · info · IllegalStateException

Query aborted by user

Error message

Query aborted by user

What it means

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.

Source

Thrown at presto-plan-checker-router-plugin/src/main/java/com/facebook/presto/router/scheduler/PlanCheckerRouterPluginPrestoClient.java:100

    public Optional<URI> getCompatibleClusterURI(Map<String, List<String>> headers, String statement, Principal principal)
    {
        String newSql = ANALYZE_CALL + statement;
        ClientSession clientSession = parseHeadersToClientSession(headers, principal, getPlanCheckerClusterDestination());
        boolean isNativeCompatible = true;
        // submit initial query
        try (StatementClient client = newStatementClient(httpClient, clientSession, newSql)) {
            // read query output
            while (client.isRunning()) {
                log.debug((client.currentData().toString()));

                if (!client.advance()) {
                    break;
                }
            }

            // verify final state
            if (client.isClientAborted()) {
                throw new IllegalStateException("Query aborted by user");
            }

            if (client.isClientError()) {
                throw new IllegalStateException("Query is gone (server restarted?)");
            }

            verify(client.isFinished());
            QueryError resultsError = client.finalStatusInfo().getError();
            if (resultsError != null) {
                isNativeCompatible = false;
                log.info(resultsError.getMessage());
            }
        }
        catch (Exception e) {
            if (javaClusterFallbackEnabled) {
                // If any exception is thrown, log the message and re-route to a Java clusters router.
                isNativeCompatible = false;
                log.info(e.getMessage());

View on GitHub (pinned to 55bb57d202)

Solutions

  1. This is an expected cancellation path: handle/catch it as user cancellation rather than retrying
  2. If unexpected, audit the caller for premature close()/cancel() of the statement client
  3. Increase client timeouts if aggressive deadlines are aborting requests before a cluster is found

Example fix

// before
URI uri = client.getCompatibleClusterURI(...); // may throw
// after
try { uri = client.getCompatibleClusterURI(...); }
catch (IllegalStateException e) { if (!e.getMessage().contains("aborted by user")) throw e; /* treat as cancellation */ }
Defensive patterns

Strategy: try-catch

Try / catch

try { uri = client.getCompatibleClusterURI(request); }
catch (IllegalStateException e) {
    if ("Query aborted by user".equals(e.getMessage())) { markCancelled(); return; }
    throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: User hits Ctrl-C or client timeout, application shuts down a query in flight, driver-level cancellation propagating to the plan-checker router client.

Related errors


AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04). Data as JSON: /api/errors/fe11f76e0eb27bb0. Report an issue: GitHub.