Cancel a task Technical preview
A task may continue to run for some time after it has been cancelled because it may not be able to safely stop its current activity straight away. It is also possible that Elasticsearch must complete its work on other tasks before it can process the cancellation. The get task information API will continue to list these cancelled tasks until they complete. The cancelled flag in the response indicates that the cancellation command has been processed and the task will stop as soon as possible.
To troubleshoot why a cancelled task does not complete promptly, use the get task information API with the ?detailed
parameter to identify the other tasks the system is running.
You can also use the node hot threads API to obtain detailed information about the work the system is doing instead of completing the cancelled task.
Path parameters
-
ID of the task.
Query parameters
-
actions string | array[string]
Comma-separated list or wildcard expression of actions used to limit the request.
-
nodes array[string]
Comma-separated list of node IDs or names used to limit the request.
-
parent_task_id string
Parent task ID used to limit the tasks.
-
wait_for_completion boolean
Should the request block until the cancellation of the task and its descendant tasks is completed. Defaults to false
curl \
-X POST http://api.example.com/_tasks/{task_id}/_cancel
{
"node_failures": [
{
"type": "string",
"reason": "string",
"stack_trace": "string",
"caused_by": {},
"root_cause": [
{}
],
"suppressed": [
{}
]
}
],
"task_failures": [
{
"task_id": 42.0,
"node_id": "string",
"status": "string",
"reason": {
"type": "string",
"reason": "string",
"stack_trace": "string",
"caused_by": {},
"root_cause": [
{}
],
"suppressed": [
{}
]
}
}
],
"nodes": {
"additionalProperty1": {
"name": "string",
"transport_address": "string",
"host": "string",
"ip": "string",
"roles": [
"string"
],
"attributes": {
"additionalProperty1": "string",
"additionalProperty2": "string"
},
"tasks": {
"additionalProperty1": {
"action": "string",
"cancelled": true,
"cancellable": true,
"description": "string",
"headers": {
"additionalProperty1": "string",
"additionalProperty2": "string"
},
"id": 42.0,
"node": "string",
"running_time": "string",
"": "string",
"status": {},
"type": "string"
},
"additionalProperty2": {
"action": "string",
"cancelled": true,
"cancellable": true,
"description": "string",
"headers": {
"additionalProperty1": "string",
"additionalProperty2": "string"
},
"id": 42.0,
"node": "string",
"running_time": "string",
"": "string",
"status": {},
"type": "string"
}
}
},
"additionalProperty2": {
"name": "string",
"transport_address": "string",
"host": "string",
"ip": "string",
"roles": [
"string"
],
"attributes": {
"additionalProperty1": "string",
"additionalProperty2": "string"
},
"tasks": {
"additionalProperty1": {
"action": "string",
"cancelled": true,
"cancellable": true,
"description": "string",
"headers": {
"additionalProperty1": "string",
"additionalProperty2": "string"
},
"id": 42.0,
"node": "string",
"running_time": "string",
"": "string",
"status": {},
"type": "string"
},
"additionalProperty2": {
"action": "string",
"cancelled": true,
"cancellable": true,
"description": "string",
"headers": {
"additionalProperty1": "string",
"additionalProperty2": "string"
},
"id": 42.0,
"node": "string",
"running_time": "string",
"": "string",
"status": {},
"type": "string"
}
}
}
},
"": [
{
"action": "string",
"cancelled": true,
"cancellable": true,
"description": "string",
"headers": {
"additionalProperty1": "string",
"additionalProperty2": "string"
},
"id": 42.0,
"node": "string",
"running_time": "string",
"": "string",
"status": {},
"type": "string"
}
]
}