ES|QL: Collect profile information for FORK and fix race condition with markEndQuery #127328
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
fix for the following test failures:
#127326
#127063
We would expect that the final listener for the main coordinator plan is called after all the final listener for the sub plans have executed.
This is the final listener for the main coordinator plan:
elasticsearch/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plugin/ComputeService.java
Lines 237 to 244 in 8f9c96b
This is the final listener for the sub plans:
elasticsearch/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plugin/ComputeService.java
Lines 360 to 364 in 8f9c96b
Currently the listeners for the sub plans can be called after we call the main plan one.
This can easily tested with a debugger by adding a
Thread.sleep
in the sub plan listener.This caused issues with how we report
took
time (see #127063 (comment)).Another issue that we currently have with FORK is that we don't collect proper profile information.
The root cause is that we don't use the same
ComputeListener
for both the main coordinator plan and sub plans.We only use it for the main coordinator plan - see how we call
localListener.acquireCompute()
.elasticsearch/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plugin/ComputeService.java
Lines 236 to 247 in 8f9c96b
To fix this I made sure that for each sub plan we also use
localListener.acquireCompute()
.The
ComputeListener
receives an action listener that will be called after each task that's created with#acquireCompute
is finished:elasticsearch/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plugin/ComputeListener.java
Lines 18 to 39 in 49a9137
This change also ensures that we are now collecting driver information from sub plans.
As a follow up I'd like to see if we can label the driver information from the profile response so it's more obvious to which sub plan it belongs to.