Skip to content
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

[Transform] Shutdown the task immediately when force == true #100203

Merged
merged 7 commits into from
Oct 9, 2023
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
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();
przemekwitek marked this conversation as resolved.
Show resolved Hide resolved
// 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;
przemekwitek marked this conversation as resolved.
Show resolved Hide resolved
}
// 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