Skip to content

[8.19] Fix testStopQueryLocal (#131130) #131145

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 2 commits into from
Jul 15, 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 @@ -374,9 +374,6 @@ tests:
- class: org.elasticsearch.xpack.esql.action.CrossClusterQueryWithPartialResultsIT
method: testOneRemoteClusterPartial
issue: https://github.com/elastic/elasticsearch/issues/124055
- class: org.elasticsearch.xpack.esql.action.CrossClusterAsyncQueryStopIT
method: testStopQueryLocal
issue: https://github.com/elastic/elasticsearch/issues/121672
- class: org.elasticsearch.gradle.internal.InternalDistributionBwcSetupPluginFuncTest
method: "builds distribution from branches via archives extractedAssemble [bwcDistVersion: 8.3.0, bwcProject: staged, expectedAssembleTaskName:
extractedAssemble, #1]"
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,13 +135,21 @@ public void testStopQueryLocal() throws Exception {

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

final String asyncExecutionId = startAsyncQuery(
// 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 = 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
assertTrue(SimplePauseFieldPlugin.startEmitting.await(30, TimeUnit.SECONDS));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public final class QueryPragmas implements Writeable {
public static final Setting<Integer> EXCHANGE_CONCURRENT_CLIENTS = Setting.intSetting("exchange_concurrent_clients", 2);
public static final Setting<Integer> ENRICH_MAX_WORKERS = Setting.intSetting("enrich_max_workers", 1);

private static final Setting<Integer> TASK_CONCURRENCY = Setting.intSetting(
public static final Setting<Integer> TASK_CONCURRENCY = Setting.intSetting(
"task_concurrency",
ThreadPool.searchOrGetThreadPoolSize(EsExecutors.allocatedProcessors(Settings.EMPTY))
);
Expand Down