-
Notifications
You must be signed in to change notification settings - Fork 25.7k
Fork ES|QL execution after preMapper #132981
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
6338f0c
186cbfa
4490c8c
6a091f3
aa11a26
3a17914
dc4bb2b
1b6f2ca
fac7a98
cf40548
7df3f6e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| pr: 132981 | ||
| summary: For ES|QL execution after `preMapper` | ||
| area: ES|QL | ||
| type: enhancement | ||
| issues: [] |
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -34,7 +34,6 @@ | |||||||||||
| import org.elasticsearch.threadpool.ThreadPool; | ||||||||||||
| import org.elasticsearch.transport.RemoteClusterAware; | ||||||||||||
| import org.elasticsearch.transport.RemoteClusterService; | ||||||||||||
| import org.elasticsearch.transport.TcpTransport; | ||||||||||||
| import org.elasticsearch.xpack.esql.VerificationException; | ||||||||||||
| import org.elasticsearch.xpack.esql.action.EsqlExecutionInfo; | ||||||||||||
| import org.elasticsearch.xpack.esql.action.EsqlQueryRequest; | ||||||||||||
|
|
@@ -75,14 +74,14 @@ | |||||||||||
| import org.elasticsearch.xpack.esql.planner.premapper.PreMapper; | ||||||||||||
| import org.elasticsearch.xpack.esql.plugin.TransportActionServices; | ||||||||||||
| import org.elasticsearch.xpack.esql.telemetry.PlanTelemetry; | ||||||||||||
| import org.elasticsearch.xpack.ml.MachineLearning; | ||||||||||||
|
|
||||||||||||
| import java.util.ArrayList; | ||||||||||||
| import java.util.Collection; | ||||||||||||
| import java.util.HashMap; | ||||||||||||
| import java.util.List; | ||||||||||||
| import java.util.Map; | ||||||||||||
| import java.util.Set; | ||||||||||||
| import java.util.concurrent.ExecutorService; | ||||||||||||
| import java.util.stream.Collectors; | ||||||||||||
| import java.util.stream.Stream; | ||||||||||||
|
|
||||||||||||
|
|
@@ -114,13 +113,14 @@ public interface PlanRunner { | |||||||||||
| private final LogicalPlanPreOptimizer logicalPlanPreOptimizer; | ||||||||||||
| private final LogicalPlanOptimizer logicalPlanOptimizer; | ||||||||||||
| private final PreMapper preMapper; | ||||||||||||
|
|
||||||||||||
| private final Mapper mapper; | ||||||||||||
| private final PhysicalPlanOptimizer physicalPlanOptimizer; | ||||||||||||
|
|
||||||||||||
| private final PlanTelemetry planTelemetry; | ||||||||||||
| private final IndicesExpressionGrouper indicesExpressionGrouper; | ||||||||||||
| private final InferenceService inferenceService; | ||||||||||||
| private final RemoteClusterService remoteClusterService; | ||||||||||||
| private final ExecutorService planExecutor; | ||||||||||||
|
|
||||||||||||
| private boolean explainMode; | ||||||||||||
| private String parsedPlanString; | ||||||||||||
|
|
@@ -157,6 +157,7 @@ public EsqlSession( | |||||||||||
| this.inferenceService = services.inferenceService(); | ||||||||||||
| this.preMapper = new PreMapper(services); | ||||||||||||
| this.remoteClusterService = services.transportService().getRemoteClusterService(); | ||||||||||||
| this.planExecutor = services.transportService().getThreadPool().executor(ThreadPool.Names.SEARCH); | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| public String sessionId() { | ||||||||||||
|
|
@@ -179,8 +180,10 @@ public void execute(EsqlQueryRequest request, EsqlExecutionInfo executionInfo, P | |||||||||||
| analyzedPlan(parsed, executionInfo, request.filter(), new EsqlCCSUtils.CssPartialErrorsActionListener(executionInfo, listener) { | ||||||||||||
| @Override | ||||||||||||
| public void onResponse(LogicalPlan analyzedPlan) { | ||||||||||||
| assert ThreadPool.assertCurrentThreadPool(ThreadPool.Names.SEARCH); | ||||||||||||
| SubscribableListener.<LogicalPlan>newForked(l -> preOptimizedPlan(analyzedPlan, l)) | ||||||||||||
| .<LogicalPlan>andThen((l, p) -> preMapper.preMapper(optimizedPlan(p), l)) | ||||||||||||
| .andThenApply(p -> optimizedPlan(p)) | ||||||||||||
| .<LogicalPlan>andThen(planExecutor, null, (l, p) -> preMapper.preMapper(p, l)) | ||||||||||||
|
||||||||||||
| Rewriteable.rewriteAndFetch( | |
| new FullTextFunctionsRewritable(plan), | |
| queryRewriteContext(services, indexNames(plan)), | |
| listener.delegateFailureAndWrap((l, r) -> l.onResponse(r.plan)) | |
| ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is correct, pre mapper could fork us to number of different threads.
andThen customizes the listener supplied to the given step to fork with executor after its completion.
This is also confirmed by the updated assertions (in executeOptimizedPlan right after this is completed)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is also a place that allow to narrow down the list of thread everywhere else in this change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
java.lang.AssertionError: elasticsearch[test-cluster-0][transport_worker][T#8] not in [search, search_coordination] nor a test thread
at org.elasticsearch.threadpool.ThreadPool.assertCurrentThreadPool(ThreadPool.java:1116) ~[elasticsearch-9.2.0-SNAPSHOT.jar:?]
at org.elasticsearch.xpack.esql.session.EsqlSession.executeOptimizedPlan(EsqlSession.java:204) ~[?:?]
could still happen with
./gradlew ":x-pack:plugin:esql:qa:server:multi-node:javaRestTest" --tests "org.elasticsearch.xpack.esql.qa.multi_node.EsqlSpecIT" -Dtests.method="test {csv-spec:match-function.TestMatchWithSemanticTextWithEvalsAndOtherFunctionsAndStats}"
Looks like .<LogicalPlan>andThen((l, p) -> preMapper.preMapper(p, new ThreadedActionListener<>(planExecutor, l))) might be necessary instead of conditional forking logic in andThen
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this technically
planExecutorExecutor? 🤔