diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/execution/PlanExecutor.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/execution/PlanExecutor.java index e657175dd3fbf..0f9fcd8b362f9 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/execution/PlanExecutor.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/execution/PlanExecutor.java @@ -87,6 +87,8 @@ public void esql( planningMetricsManager.publish(planningMetrics, false); listener.onFailure(ex); }); + // Wrap it in a listener so that if we have any exceptions during execution, we the listener picks it up + // and all the metrics are properly updated ActionListener.run(executeListener, l -> session.execute(request, executionInfo, planRunner, l)); }