Skip to content

Commit

Permalink
[Transform] Shutdown the task immediately when force == true (ela…
Browse files Browse the repository at this point in the history
…stic#100203)

(cherry picked from commit 48e86ad)
  • Loading branch information
przemekwitek committed Oct 9, 2023
1 parent a1d2460 commit 0addf1b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
5 changes: 5 additions & 0 deletions docs/changelog/100203.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 100203
summary: Shutdown the task immediately when `force` == `true`
area: Transform
type: bug
issues: []
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,20 @@ protected void taskOperation(
}

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

0 comments on commit 0addf1b

Please sign in to comment.