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
- Read the cause of this RuntimeException — the true failure (connect timeout, refused, reset) is there.
- Check whether the worker host in the URL is alive and reachable (ping/curl the endpoint).
- Retry the request; Presto's retry logic often recovers from transient worker loss.
- Increase the client's connect/read timeouts if the failure is a timeout under load.
- 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
- Set explicit, load-tested OkHttp connect/read timeouts.
- Track worker liveness and stop sending requests to dead hosts.
- Distinguish timeout vs refused vs reset from the cause chain before retrying.
- Keep the Spark-to-worker network path (ports, security groups, DNS) verified.
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
- Error reading response from server
- Expected response code to be 200, but was %s:%n%s
- Error fetching next (attempts: %s, duration: %s)
- INVALID_ARGUMENTS
- PINOT_HTTP_ERROR
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/268a4ac55aca6fec.
Report an issue: GitHub.