prestodb/presto · warning · RuntimeException

StatementClient thread was interrupted

Error message

StatementClient thread was interrupted

What it means

While backing off between retry attempts inside advance(), the sleep can be interrupted; the client closes itself, re-asserts the interrupt flag, sets CLIENT_ERROR, and throws RuntimeException 'StatementClient thread was interrupted'. This signals that another thread cancelled the statement client's worker, typically during shutdown.

Source

Thrown at presto-client/src/main/java/com/facebook/presto/client/StatementClientV1.java:408

            if (attempts > 0 && sinceStart.compareTo(requestTimeoutNanos) > 0) {
                state.compareAndSet(State.RUNNING, State.CLIENT_ERROR);
                throw new RuntimeException(format("Error fetching next (attempts: %s, duration: %s)", attempts, sinceStart), cause);
            }

            if (attempts > 0) {
                // back-off on retry
                try {
                    MILLISECONDS.sleep(attempts * 100);
                }
                catch (InterruptedException e) {
                    try {
                        close();
                    }
                    finally {
                        Thread.currentThread().interrupt();
                    }
                    state.compareAndSet(State.RUNNING, State.CLIENT_ERROR);
                    throw new RuntimeException("StatementClient thread was interrupted");
                }
            }
            attempts++;

            JsonResponse<QueryResults> response;
            try {
                response = JsonResponse.execute(QUERY_RESULTS_CODEC, httpClient, request);
            }
            catch (RuntimeException e) {
                cause = e;
                continue;
            }

            if ((response.getStatusCode() == HTTP_OK) && response.hasValue()) {
                processResponse(response.getHeaders(), response.getValue());
                return true;
            }

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Treat this as cancellation: do not retry blindly; check your application's shutdown/cancel logic.
  2. Avoid interrupting the thread running the statement client unless cancellation is intended; use client.close()/cancelLeafStage for orderly stop.
  3. Ensure cancel(true) is only called on futures you intend to abort.
  4. If seen unexpectedly, audit thread-pool lifecycle (shutdownNow vs shutdown) in your code.

Example fix

// before
executor.shutdownNow();  // interrupts in-flight Presto fetch
// after
client.close();
executor.shutdown();
executor.awaitTermination(30, TimeUnit.SECONDS);
Defensive patterns

Strategy: try-catch

Try / catch

try {
    while (client.isRunning()) client.advance();
} catch (RuntimeException e) {
    if (Thread.currentThread().isInterrupted() || "StatementClient thread was interrupted".equals(e.getMessage())) {
        // treat as cancellation: clean up, don't retry
    } else throw e;
}

Prevention

When it happens

Trigger: Calling advance() and having Thread.interrupt() invoked on the executing thread while it sleeps between retries — e.g. executor shutdownNow(), future.cancel(true), or application shutdown hooks.

Common situations: Cancelling a query future with cancel(true); shutting down an ExecutorService running Presto queries; JVM shutdown while a CLI/JDBC fetch is in its retry backoff.

Related errors


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