Skip to content

Commit bb9c2c3

Browse files
authored
Separate stop flag and is_partial (#122654)
1 parent 2e3cf38 commit bb9c2c3

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlExecutionInfo.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ public class EsqlExecutionInfo implements ChunkedToXContentObject, Writeable {
7676
private final transient Long relativeStartNanos; // start time for an ESQL query for calculating took times
7777
private transient TimeValue planningTookTime; // time elapsed since start of query to calling ComputeService.execute
7878
private volatile boolean isPartial; // Does this request have partial results?
79+
private transient volatile boolean isStopped; // Have we received stop command?
7980

8081
public EsqlExecutionInfo(boolean includeCCSMetadata) {
8182
this(Predicates.always(), includeCCSMetadata); // default all clusters to skip_unavailable=true
@@ -311,6 +312,14 @@ public void markAsPartial() {
311312
isPartial = true;
312313
}
313314

315+
public void markAsStopped() {
316+
isStopped = true;
317+
}
318+
319+
public boolean isStopped() {
320+
return isStopped;
321+
}
322+
314323
/**
315324
* Mark this cluster as having partial results.
316325
*/

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plugin/ComputeService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ public void execute(
251251
exchangeSource,
252252
cancelQueryOnFailure,
253253
localListener.acquireCompute().map(r -> {
254-
localClusterWasInterrupted.set(execInfo.isPartial());
254+
localClusterWasInterrupted.set(execInfo.isStopped());
255255
if (execInfo.isCrossClusterSearch() && execInfo.clusterAliases().contains(LOCAL_CLUSTER)) {
256256
execInfo.swapCluster(
257257
LOCAL_CLUSTER,
@@ -292,7 +292,7 @@ public void execute(
292292
private void updateExecutionInfo(EsqlExecutionInfo executionInfo, String clusterAlias, ComputeResponse resp) {
293293
Function<EsqlExecutionInfo.Cluster.Status, EsqlExecutionInfo.Cluster.Status> runningToSuccess = status -> {
294294
if (status == EsqlExecutionInfo.Cluster.Status.RUNNING) {
295-
return executionInfo.isPartial() ? EsqlExecutionInfo.Cluster.Status.PARTIAL : EsqlExecutionInfo.Cluster.Status.SUCCESSFUL;
295+
return executionInfo.isStopped() ? EsqlExecutionInfo.Cluster.Status.PARTIAL : EsqlExecutionInfo.Cluster.Status.SUCCESSFUL;
296296
} else {
297297
return status;
298298
}

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plugin/TransportEsqlAsyncStopAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ private void stopQueryAndReturnResult(Task task, AsyncExecutionId asyncId, Actio
118118
logger.debug("Async stop for task {} - stopping", asyncIdStr);
119119
final EsqlExecutionInfo esqlExecutionInfo = asyncTask.executionInfo();
120120
if (esqlExecutionInfo != null) {
121-
esqlExecutionInfo.markAsPartial();
121+
esqlExecutionInfo.markAsStopped();
122122
}
123123
Runnable getResults = () -> getResultsAction.execute(task, getAsyncResultRequest, listener);
124124
exchangeService.finishSessionEarly(sessionID(asyncId), ActionListener.running(() -> {

0 commit comments

Comments
 (0)