{"record":{"id":"268a4ac55aca6fec","repo":"prestodb/presto","slug":"failed-to-execute-request","errorCode":null,"errorMessage":"Failed to execute request: ","messagePattern":"Failed to execute request: ","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"presto-spark-base/src/main/java/com/facebook/presto/spark/execution/http/server/smile/AdaptingJsonResponseHandler.java","lineNumber":48,"sourceCode":"public class AdaptingJsonResponseHandler<T>\n        implements OkHttpResponseHandler<T>\n{\n    private final JsonCodec<T> jsonCodec;\n\n    private AdaptingJsonResponseHandler(JsonCodec<T> jsonCodec)\n    {\n        this.jsonCodec = requireNonNull(jsonCodec, \"jsonCodec is null\");\n    }\n\n    public static <T> AdaptingJsonResponseHandler<T> createAdaptingJsonResponseHandler(JsonCodec<T> jsonCodec)\n    {\n        return new AdaptingJsonResponseHandler<>(jsonCodec);\n    }\n\n    public BaseResponse<T> handleException(Request request, Exception exception)\n            throws RuntimeException\n    {\n        throw new RuntimeException(\"Failed to execute request: \" + request.url(), exception);\n    }\n\n    public BaseResponse<T> handle(Request request, Response response)\n            throws IOException\n    {\n        return new OkHttpBaseResponse<>(response, jsonCodec);\n    }\n}\n","sourceCodeStart":30,"sourceCodeEnd":57,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-spark-base/src/main/java/com/facebook/presto/spark/execution/http/server/smile/AdaptingJsonResponseHandler.java#L30-L57","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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)."],"exampleFix":"// instead of letting the RuntimeException propagate and kill the caller\ntry {\n    BaseResponse<TaskInfo> response = handler.handle(request, response);\n} catch (RuntimeException e) {\n    if (e.getCause() instanceof SocketTimeoutException) {\n        // retry with backoff against the same URL\n        retryRequest(request, e);\n    } else {\n        throw e;\n    }\n}","handlingStrategy":"try-catch","validationCode":"// pre-flight reachability check before issuing the JSON request\nboolean reachable = isReachable(workerHost, workerPort, Duration.ofSeconds(2));\nif (!reachable) throw new IOException(\"Worker unreachable before request: \" + workerHost + \":\" + workerPort);","typeGuard":null,"tryCatchPattern":"try {\n    BaseResponse<T> resp = responseHandler.handle(request, response);\n} catch (RuntimeException e) {\n    Throwable cause = e.getCause();\n    if (cause instanceof SocketTimeoutException || cause instanceof ConnectException) {\n        // transient network failure: retry with backoff / fail over to another worker\n    }\n    throw e;\n}","preventionTips":["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."],"tags":["http","network","okhttp","spark"],"backgroundTag":"failed-to-execute-request","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"}