Skip to content

Fix testStopQueryLocal #131130

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

Merged
merged 1 commit into from
Jul 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions muted-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -531,9 +531,6 @@ tests:
- class: org.elasticsearch.indices.stats.IndexStatsIT
method: testFilterCacheStats
issue: https://github.com/elastic/elasticsearch/issues/124447
- class: org.elasticsearch.xpack.esql.action.CrossClusterAsyncQueryStopIT
method: testStopQueryLocal
issue: https://github.com/elastic/elasticsearch/issues/121672
- class: org.elasticsearch.backwards.MixedClusterClientYamlTestSuiteIT
method: test {p0=mtermvectors/10_basic/Tests catching other exceptions per item}
issue: https://github.com/elastic/elasticsearch/issues/122414
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@
import org.elasticsearch.logging.LogManager;
import org.elasticsearch.logging.Logger;
import org.elasticsearch.tasks.TaskInfo;
import org.elasticsearch.transport.TransportService;
import org.elasticsearch.xpack.core.async.AsyncStopRequest;
import org.elasticsearch.xpack.esql.plugin.EsqlPlugin;
import org.elasticsearch.xpack.esql.plugin.QueryPragmas;

import java.util.Iterator;
import java.util.List;
Expand Down Expand Up @@ -132,14 +135,21 @@ public void testStopQueryLocal() throws Exception {

Tuple<Boolean, Boolean> includeCCSMetadata = randomIncludeCCSMetadata();
boolean responseExpectMeta = includeCCSMetadata.v2();

// By default, ES|QL uses all workers in the esql_worker threadpool to execute drivers on data nodes.
// If a node is both data and coordinator, and all drivers are blocked by the allowEmitting latch,
// there are no workers left to execute the final driver or fetch pages from remote clusters.
// This can prevent remote clusters from being marked as successful on the coordinator, even if they
// have completed. To avoid this, we reserve at least one worker for the final driver and page fetching.
// A single worker is enough, as these two tasks can be paused and yielded.
var threadpool = cluster(LOCAL_CLUSTER).getInstance(TransportService.class).getThreadPool();
int maxEsqlWorkers = threadpool.info(EsqlPlugin.ESQL_WORKER_THREAD_POOL_NAME).getMax();
LOGGER.info("--> Launching async query");
final String asyncExecutionId = startAsyncQuery(
final String asyncExecutionId = startAsyncQueryWithPragmas(
client(),
"FROM blocking,*:logs-* | STATS total=sum(coalesce(const,v)) | LIMIT 1",
includeCCSMetadata.v1()
includeCCSMetadata.v1(),
Map.of(QueryPragmas.TASK_CONCURRENCY.getKey(), between(1, maxEsqlWorkers - 1))
);

try {
// wait until we know that the local query against 'blocking' has started
LOGGER.info("--> Waiting for {} to start", asyncExecutionId);
Expand Down