From 7832b8ce8252b0a36ab8260bbfb38456aa59c1f1 Mon Sep 17 00:00:00 2001 From: "ievgen.degtiarenko" Date: Fri, 1 Aug 2025 14:23:19 +0200 Subject: [PATCH] Assert current thread in ESQL This change adds more assertions for current thread in ESQL --- .../elasticsearch/xpack/esql/session/EsqlSession.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/session/EsqlSession.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/session/EsqlSession.java index 34ece5661c8d7..c1a4d0d9a3ba0 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/session/EsqlSession.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/session/EsqlSession.java @@ -365,6 +365,7 @@ public void analyzedPlan( QueryBuilder requestFilter, ActionListener logicalPlanListener ) { + assert ThreadPool.assertCurrentThreadPool(ThreadPool.Names.SEARCH); if (parsed.analyzed()) { logicalPlanListener.onResponse(parsed); return; @@ -448,6 +449,11 @@ private void preAnalyzeLookupIndex( String localPattern = lookupIndexPattern.indexPattern(); assert RemoteClusterAware.isRemoteIndexName(localPattern) == false : "Lookup index name should not include remote, but got: " + localPattern; + assert ThreadPool.assertCurrentThreadPool( + ThreadPool.Names.SEARCH, + ThreadPool.Names.SEARCH_COORDINATION, + ThreadPool.Names.SYSTEM_READ + ); Set fieldNames = result.wildcardJoinIndices().contains(localPattern) ? IndexResolver.ALL_FIELDS : result.fieldNames; String patternWithRemotes; @@ -633,6 +639,11 @@ private void preAnalyzeMainIndices( QueryBuilder requestFilter, ActionListener listener ) { + assert ThreadPool.assertCurrentThreadPool( + ThreadPool.Names.SEARCH, + ThreadPool.Names.SEARCH_COORDINATION, + ThreadPool.Names.SYSTEM_READ + ); // TODO we plan to support joins in the future when possible, but for now we'll just fail early if we see one List indices = preAnalysis.indices; if (indices.size() > 1) {