Skip to content

Commit 08cef09

Browse files
authored
[Transform] Shutdown the task immediately when force == true (#100203) (#100504)
1 parent a1f7741 commit 08cef09

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

docs/changelog/100203.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 100203
2+
summary: Shutdown the task immediately when `force` == `true`
3+
area: Transform
4+
type: bug
5+
issues: []

x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/action/TransportStopTransformAction.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,20 @@ protected void taskOperation(
241241
}
242242

243243
if (ids.contains(transformTask.getTransformId())) {
244+
if (request.isForce()) {
245+
// If force==true, we skip the additional step (setShouldStopAtCheckpoint) and move directly to shutting down the task.
246+
// This way we ensure that the persistent task is removed ASAP (as opposed to being removed in one of the listeners).
247+
try {
248+
// Here the task is deregistered in scheduler and marked as completed in persistent task service.
249+
transformTask.shutdown();
250+
// Here the indexer is aborted so that its thread finishes work ASAP.
251+
transformTask.onCancelled();
252+
listener.onResponse(new Response(true));
253+
} catch (ElasticsearchException ex) {
254+
listener.onFailure(ex);
255+
}
256+
return;
257+
}
244258
// move the call to the generic thread pool, so we do not block the network thread
245259
threadPool.generic().execute(() -> {
246260
transformTask.setShouldStopAtCheckpoint(request.isWaitForCheckpoint(), ActionListener.wrap(r -> {

0 commit comments

Comments
 (0)