Skip to content

Commit 7a0efec

Browse files
authored
[8.x] Separate stop flag and is_partial (#122654) (#122659)
* Separate stop flag and is_partial (#122654) * fix test
1 parent 20d2330 commit 7a0efec

File tree

4 files changed

+12
-4
lines changed

4 files changed

+12
-4
lines changed

x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/CrossClusterAsyncQueryStopIT.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,6 @@ public void testStopQueryLocal() throws Exception {
156156
try (EsqlQueryResponse asyncResponse = getAsyncResponse(client(), asyncExecutionId)) {
157157
EsqlExecutionInfo executionInfo = asyncResponse.getExecutionInfo();
158158
assertNotNull(executionInfo);
159-
assertThat(executionInfo.isPartial(), is(true));
160159
}
161160
});
162161
// allow local query to proceed

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
@@ -73,6 +73,7 @@ public class EsqlExecutionInfo implements ChunkedToXContentObject, Writeable {
7373
private final transient Long relativeStartNanos; // start time for an ESQL query for calculating took times
7474
private transient TimeValue planningTookTime; // time elapsed since start of query to calling ComputeService.execute
7575
private volatile boolean isPartial; // Does this request have partial results?
76+
private transient volatile boolean isStopped; // Have we received stop command?
7677

7778
public EsqlExecutionInfo(boolean includeCCSMetadata) {
7879
this(Predicates.always(), includeCCSMetadata); // default all clusters to skip_unavailable=true
@@ -300,6 +301,14 @@ public void markAsPartial() {
300301
isPartial = true;
301302
}
302303

304+
public void markAsStopped() {
305+
isStopped = true;
306+
}
307+
308+
public boolean isStopped() {
309+
return isStopped;
310+
}
311+
303312
/**
304313
* Mark this cluster as having partial results.
305314
*/

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
@@ -249,7 +249,7 @@ public void execute(
249249
exchangeSource,
250250
cancelQueryOnFailure,
251251
localListener.acquireCompute().map(r -> {
252-
localClusterWasInterrupted.set(execInfo.isPartial());
252+
localClusterWasInterrupted.set(execInfo.isStopped());
253253
if (execInfo.isCrossClusterSearch() && execInfo.clusterAliases().contains(LOCAL_CLUSTER)) {
254254
execInfo.swapCluster(
255255
LOCAL_CLUSTER,
@@ -290,7 +290,7 @@ public void execute(
290290
private void updateExecutionInfo(EsqlExecutionInfo executionInfo, String clusterAlias, ComputeResponse resp) {
291291
Function<EsqlExecutionInfo.Cluster.Status, EsqlExecutionInfo.Cluster.Status> runningToSuccess = status -> {
292292
if (status == EsqlExecutionInfo.Cluster.Status.RUNNING) {
293-
return executionInfo.isPartial() ? EsqlExecutionInfo.Cluster.Status.PARTIAL : EsqlExecutionInfo.Cluster.Status.SUCCESSFUL;
293+
return executionInfo.isStopped() ? EsqlExecutionInfo.Cluster.Status.PARTIAL : EsqlExecutionInfo.Cluster.Status.SUCCESSFUL;
294294
} else {
295295
return status;
296296
}

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)