Elasticsearch Elasticsearch Long Running Stuck Tasks

By Opster Team

Updated: Mar 10, 2024

| 2 min read

What does this mean?

Long running stuck tasks are tasks in Elasticsearch that have been running for an extended period of time without completion (currently 1 day or 1440 minutes). These tasks may be stuck due to various reasons, such as resource constraints, bugs, or other issues. Stuck tasks can negatively impact the performance and stability of the Elasticsearch cluster

Why does this occur?

There are several reasons why tasks may become stuck in Elasticsearch:

1. Resource constraints: The task may be waiting for resources, such as CPU, memory, or disk space, which are not available due to other tasks or processes consuming them.

2. Bugs or issues in the Elasticsearch code: There may be a bug or issue in the Elasticsearch code that is causing the task to hang indefinitely.

3. Configuration issues: Incorrect or suboptimal configuration settings may cause tasks to become stuck.

4. Network issues: Connectivity problems between nodes in the cluster can lead to tasks becoming stuck.

Possible impact and consequences of long running stuck tasks

The impact of long running stuck tasks in Elasticsearch can be significant, including:

1. Reduced cluster performance: Stuck tasks consume resources and can cause other tasks to be delayed or fail, leading to overall reduced performance.

2. Cluster instability: Long running stuck tasks can cause the cluster to become unstable, leading to potential data loss or corruption.

3. Increased troubleshooting and maintenance time: Identifying and resolving the root cause of stuck tasks can be time-consuming and resource-intensive.

How to resolve

To resolve the issue of long running stuck tasks in Elasticsearch, follow these steps:

1. Identify the stuck tasks: Use one of the following commands to list all tasks currently running in the cluster. Note that the first one is a bit more condensed and tasks are sorted by the longest running tasks first, so it’s easier to spot them:

GET _cat/tasks?v&detailed=true
GET /_tasks?detailed=true

Also note that some tasks, such as continuous transforms and the GeoIP downloader, are meant to be running constantly.

2. Cancel the long-running tasks: To improve cluster stability, cancel the tasks that have been running for an extended period of time. Use the following command to cancel a specific task:

POST /_tasks/<task_id>/_cancel

3. Resolve non-cancellable tasks: Some tasks may not be cancellable. In this case, you need to clear the stuck tasks by restarting the nodes they are running on. First, identify the node where the task is running using the output from the `_tasks` API. Then, perform a rolling restart of the affected nodes to minimize the impact on the cluster.

4. Investigate the root cause: After resolving the immediate issue, investigate the root cause of the stuck tasks. This may involve reviewing logs, monitoring resource usage, and checking for any known issues or bugs in the Elasticsearch version being used.

5. Optimize configurations: Review and optimize Elasticsearch configurations to ensure that they are not contributing to the issue. This may include adjusting settings related to resource allocation, timeouts, and thread pools.


Long running stuck tasks in Elasticsearch can have a significant impact on cluster performance and stability. By following this guide, you can identify, resolve, and prevent these issues to maintain a healthy and efficient Elasticsearch cluster.

How helpful was this guide?

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?