
I had a problem with long-running stuck tasks. These tasks were stuck due to various reasons, such as resource constraints, bugs, or other issues.
How I resolved it:
I followed these steps:
1) You need to identify the stuck tasks by using the command below
GET _cat/tasks?v&h=id,ip,action,type,task_id,timestamp,running_time
When you use the above command, you will get lists of all long-running stuck tasks:

2) If you want or need to get details for a long-running stuck task, use this command:
GET _tasks?actions=*<action>/&detailed
When you use the above command, you will get all the details of the chosen task:

3) To cancel the long-running tasks, use this command:
POST /_tasks/<task_id>/_cancel
If all is finished successfully, you will get:

4) Rarely it could be impossible to cancel a task. In this case, you need to clear the stuck task by restarting the node.
First, identify the node where the task is running using the output from
GET /_cat/tasks?format=json
Then, restart the nodes where the task is running.
The post How to Check What Task is Stuck and Cancel it on Dev-tools appeared first on SOC Prime.