prestodb/presto · error · RuntimeException

Failed to execute request:

Error message

Failed to execute request: 

What it means

AdaptingJsonResponseHandler.handleException is OkHttp's failure callback for JSON control-plane requests (e.g. task info/status calls). It unconditionally wraps any transport-level exception in a RuntimeException prefixed 'Failed to execute request: <url>', preserving the original exception as the cause so the caller sees both the URL and the network failure.

Source

Thrown at presto-spark-base/src/main/java/com/facebook/presto/spark/execution/http/server/smile/AdaptingJsonResponseHandler.java:48

public class AdaptingJsonResponseHandler<T>
        implements OkHttpResponseHandler<T>
{
    private final JsonCodec<T> jsonCodec;

    private AdaptingJsonResponseHandler(JsonCodec<T> jsonCodec)
    {
        this.jsonCodec = requireNonNull(jsonCodec, "jsonCodec is null");
    }

    public static <T> AdaptingJsonResponseHandler<T> createAdaptingJsonResponseHandler(JsonCodec<T> jsonCodec)
    {
        return new AdaptingJsonResponseHandler<>(jsonCodec);
    }

    public BaseResponse<T> handleException(Request request, Exception exception)
            throws RuntimeException
    {
        throw new RuntimeException("Failed to execute request: " + request.url(), exception);
    }

    public BaseResponse<T> handle(Request request, Response response)
            throws IOException
    {
        return new OkHttpBaseResponse<>(response, jsonCodec);
    }
}

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Read the cause of this RuntimeException — the true failure (connect timeout, refused, reset) is there.
  2. Check whether the worker host in the URL is alive and reachable (ping/curl the endpoint).
  3. Retry the request; Presto's retry logic often recovers from transient worker loss.
  4. Increase the client's connect/read timeouts if the failure is a timeout under load.
  5. Verify network policy/firewall allows the driver-to-worker port and that the worker was not replaced (stale host address).

Example fix

// instead of letting the RuntimeException propagate and kill the caller
try {
    BaseResponse<TaskInfo> response = handler.handle(request, response);
} catch (RuntimeException e) {
    if (e.getCause() instanceof SocketTimeoutException) {
        // retry with backoff against the same URL
        retryRequest(request, e);
    } else {
        throw e;
    }
}
Defensive patterns

Strategy: try-catch

Validate before calling

// pre-flight reachability check before issuing the JSON request
boolean reachable = isReachable(workerHost, workerPort, Duration.ofSeconds(2));
if (!reachable) throw new IOException("Worker unreachable before request: " + workerHost + ":" + workerPort);

Try / catch

try {
    BaseResponse<T> resp = responseHandler.handle(request, response);
} catch (RuntimeException e) {
    Throwable cause = e.getCause();
    if (cause instanceof SocketTimeoutException || cause instanceof ConnectException) {
        // transient network failure: retry with backoff / fail over to another worker
    }
    throw e;
}

Prevention

When it happens

Trigger: OkHttp invokes handleException when the request itself fails before a response is received: connect timeout, read timeout, connection refused/reset, DNS failure, or socket interruption during a getTaskInfo/status call.

Common situations: Worker died or was preempted mid-query so its HTTP endpoint stopped answering; network partition between Spark driver/executor and worker; too-short read timeout under load; worker port closed by firewall/security group; Kubernetes pod rescheduled.

Related errors


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