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 f39e5d0cba0a1..734cfe79f4d23 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 @@ -364,6 +364,7 @@ public void analyzedPlan( QueryBuilder requestFilter, ActionListener logicalPlanListener ) { + assert ThreadPool.assertCurrentThreadPool(ThreadPool.Names.SEARCH); if (parsed.analyzed()) { logicalPlanListener.onResponse(parsed); return; @@ -440,6 +441,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; @@ -625,6 +631,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) {