prestodb/presto · error · PrestoException

INVALID_ARGUMENTS

INVALID_ARGUMENTS

Error message

Failed to get optimized expressions from sidecar.

What it means

This PrestoException (INVALID_ARGUMENTS) is thrown by NativeSidecarExpressionInterpreter.optimize when the HTTP call to the native sidecar expression-optimization endpoint fails for any reason — connection errors, timeouts, non-2xx responses, or deserialization failures of the response. The original exception is attached as the cause; the message is generic.

Source

Thrown at presto-native-sidecar-plugin/src/main/java/com/facebook/presto/sidecar/expressions/NativeSidecarExpressionInterpreter.java:126

        Map<RowExpression, RowExpression> result = new IdentityHashMap<>();
        for (int i = 0; i < rowExpressionOptimizationResults.size(); i++) {
            result.put(originalExpressions.get(i), rowExpressionOptimizationResults.get(i).getOptimizedExpression());
        }
        return unmodifiableMap(result);
    }

    public List<RowExpressionOptimizationResult> optimize(ConnectorSession session, ExpressionOptimizer.Level level, List<RowExpression> resolvedExpressions)
    {
        List<RowExpressionOptimizationResult> optimizedExpressions;
        long start = System.nanoTime();
        try {
            optimizedExpressions = httpClient.execute(
                    getSidecarRequest(session, level, resolvedExpressions),
                    createJsonResponseHandler(rowExpressionOptimizationResultJsonCodec));
        }
        catch (Exception e) {
            throw new PrestoException(INVALID_ARGUMENTS, "Failed to get optimized expressions from sidecar.", e);
        }
        finally {
            Duration duration = new Duration(System.nanoTime() - start, TimeUnit.NANOSECONDS);
            latency.add(duration);
            log.debug("queryId=%s, expression optimization latencyMs=%d", session.getQueryId(), duration.toMillis());
        }
        return optimizedExpressions;
    }

    @Managed
    @Nested
    public TimeStat getLatency()
    {
        return latency;
    }

    private Request getSidecarRequest(ConnectorSession session, Level level, List<RowExpression> resolvedExpressions)
    {

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Check the cause exception to distinguish connection refused vs timeout vs HTTP error
  2. Verify the sidecar service is healthy and reachable (health endpoint, service discovery, URI config)
  3. Confirm sidecar and coordinator/native versions return compatible response schema
  4. Add/rely on retry with backoff for transient network failures, then fall back to Java expression interpreter

Example fix

// before: single hard call
optimizedExpressions = httpClient.execute(request, handler);
// after: caller-level fallback
try {
    return sidecarInterpreter.optimize(session, level, expressions);
} catch (PrestoException e) {
    log.warn(e, "sidecar optimization failed; falling back to Java");
    return javaInterpreter.optimize(session, level, expressions);
}
Defensive patterns

Strategy: retry

Validate before calling

// preflight: verify sidecar reachability before first use
try (Socket s = new Socket()) {
  s.connect(new InetSocketAddress(sidecarHost, sidecarPort), 2000); // throws if unreachable
}

Try / catch

try {
  return interpreter.optimize(session, level, expressions);
} catch (PrestoException e) {
  if (isTransient(e.getCause())) { // IOException, timeout
    return retryWithBackoff(() -> interpreter.optimize(session, level, expressions), 3);
  }
  // persistent failure: fall back to Java expression interpreter
  return javaInterpreter.optimize(session, level, expressions);
}

Prevention

When it happens

Trigger: httpClient.execute for the sidecar request throws: sidecar service down/unscaled, DNS or network failure, request timeout, sidecar returning 5xx/4xx, or response JSON not matching rowExpressionOptimizationResultJsonCodec.

Common situations: Sidecar deployment not running or autoscaled to zero; wrong sidecar URI/port in config; network/security-group blocking worker→sidecar traffic; version skew producing incompatible response schema.

Related errors


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