prestodb/presto · critical · PrestoException

DRUID_BROKER_RESULT_ERROR

DRUID_BROKER_RESULT_ERROR

Error message

Request to worker failed

What it means

Thrown from StreamingJsonResponseHandler.handleException in DruidClient when the Airlift HTTP client fails at the transport level while sending a request to a Druid worker (broker or coordinator indexer). Any Exception raised by the HTTP client (connect failure, TLS error, timeout, connection refused) is wrapped in a DRUID_BROKER_RESULT_ERROR PrestoException with message "Request to worker failed". The original exception is preserved as the cause.

Source

Thrown at presto-druid/src/main/java/com/facebook/presto/druid/DruidClient.java:189

                .setBodyGenerator(createStaticBodyGenerator(createRequestBody(query, OBJECT_LINES, false)))
                .build();
    }

    private Request prepareDataIngestion(DruidIngestTask ingestTask)
    {
        HttpUriBuilder uriBuilder = uriBuilderFrom(druidCoordinator).replacePath(INDEXER_TASK_ENDPOINT);
        return setContentTypeHeaders(preparePost())
                .setUri(uriBuilder.build())
                .setBodyGenerator(createStaticBodyGenerator(ingestTask.toJson().getBytes()))
                .build();
    }
    private static class StreamingJsonResponseHandler
            implements ResponseHandler<InputStream, RuntimeException>
    {
        @Override
        public InputStream handleException(Request request, Exception exception)
        {
            throw new PrestoException(DRUID_BROKER_RESULT_ERROR, "Request to worker failed", exception);
        }

        @Override
        public InputStream handle(Request request, com.facebook.airlift.http.client.Response response)
        {
            try {
                if (response.getStatusCode() != HTTP_OK) {
                    String result = new BufferedReader(new InputStreamReader(response.getInputStream())).lines().collect(Collectors.joining("\n"));
                    throw new PrestoException(DRUID_BROKER_RESULT_ERROR, result);
                }
                if (APPLICATION_JSON.equals(response.getHeader(CONTENT_TYPE))) {
                    return response.getInputStream();
                }
                throw new PrestoException(DRUID_BROKER_RESULT_ERROR, "Response received was not of type " + APPLICATION_JSON);
            }
            catch (IOException e) {
                throw new PrestoException(DRUID_BROKER_RESULT_ERROR, "Unable to read response from worker", e);
            }

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Check the exception's cause for the exact transport error (Connection refused, UnknownHost, SSLHandshakeException, timeout).
  2. Verify druid-broker-url and druid-coordinator-url properties point to reachable host:port (curl the broker URL from the Presto coordinator/worker host).
  3. Confirm the Druid broker/coordinator services are running and listening (process status, listening ports).
  4. Check network paths: firewalls, security groups, DNS resolution, and TLS certificate validity if using HTTPS.
  5. Increase HTTP connect timeout settings if failures occur under load or slow network conditions.

Example fix

// before (etc/druid/druid.properties): wrong host
connector.name=druid
druid-broker-url=http://druid-broker-internal:8082

// after: correct, reachable broker endpoint (verify with curl first)
druid-broker-url=http://druid-broker.prod.internal:8082
druid-coordinator-url=http://druid-coordinator.prod.internal:8081
Defensive patterns

Strategy: validation

Validate before calling

// Preflight connectivity checks from the Presto host before running queries:
curl -sf --max-time 5 http://druid-broker:8082/status || echo "broker unreachable"
curl -sf --max-time 5 http://druid-coordinator:8081/status || echo "coordinator unreachable"
// Also verify DNS: getent hosts druid-broker.prod.internal

Try / catch

try {
    InputStream in = druidClient.getData(dql);
} catch (PrestoException e) {
    if (e.getCause() != null) {
        // Connection refused / UnknownHost / SSLHandshakeException live in the cause
        log.error("Druid transport failure: " + e.getCause().getClass().getSimpleName(), e.getCause());
    }
    throw e;
}

Prevention

When it happens

Trigger: DruidClient.getData or ingestData invokes httpClient.execute and the airlift ResponseHandler's handleException callback fires — i.e. the HTTP request to the Druid broker/coordinator never completed successfully (connect refused, DNS failure, TLS handshake failure, request timeout).

Common situations: Wrong druid-broker-url / druid-coordinator-url in Druid connector config; Druid process down or restarting; firewall/security-group blocking the port; DNS misconfiguration; certificate expiry on HTTPS endpoints.

Understand the failure class

Background: ECONNREFUSED and "connection refused" / "could not connect to server" errors: what they mean and how to fix them — this error's family across 44 libraries.

Related errors


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