Opster Team
Before you begin reading this guide, we recommend you run Elasticsearch Error Check-Up which analyzes 2 JSON files to detect many errors.
Briefly, this error message indicates that the recovery process for an index has failed. The recovery process is usually triggered when a node in the Elasticsearch cluster is restarted or when a shard is relocated to a new node. If the recovery process fails, it could be due to various reasons such as network issues, hardware failures, or corruption of the index. To resolve this issue, you can try restarting the recovery process or running the index recovery process manually. Additionally, you should investigate the root cause of the recovery failure and take the necessary steps to address the underlying issue.
To easily locate the root cause and resolve this issue try AutoOps for Elasticsearch & OpenSearch. It diagnoses problems by analyzing hundreds of metrics collected by a lightweight agent and offers guidance for resolving them. Take a self-guided product tour to see for yourself (no registration required).
This guide will help you check for common problems that cause the log ” Recovery failed ” to appear. To understand the issues related to this log, read the explanation below about the following Elasticsearch concepts: recovery.
Overview
In Elasticsearch, recovery refers to the process of recovering an index or shard when something goes wrong. There are many ways to recover an index or shard, such as by re-indexing the data from a backup / failover cluster to the current one, or by restoring from an Elasticsearch snapshot. Alternatively, Elasticsearch performs recoveries automatically, such as when a node restarts or disconnects and connects again. There is an API to check the updated status of index / shard recoveries.
GET /<index>/_recoveryGET /_recovery
In summary, recovery can happen in the following scenarios:
- Node startup or failure (local store recovery)
- Replication of primary shards to replica shards
- Relocation of a shard to a different node in the same cluster
- Restoring a snapshot
Examples
Getting recovery information about several indices:
GET my_index1 GET my_index2/_recovery
Notes and good things to know
- When a node is disconnected from the cluster, all of its shards go to an unassigned state. After a certain amount of time, the shards will be allocated somewhere else on other nodes. This setting determines the number of concurrent shards per node that will be recovered.
PUT _cluster/settings{"transient":{"cluster.routing.allocation.node_concurrent_recoveries":3}}
- You can also control when to start recovery after a node disconnects. This is useful if the node just restarts, for example, because you may not want to initiate any recovery for such transient events.
PUT _all/_settings{"settings":{"index.unassigned.node_left.delayed_timeout":"6m"}}
- Elasticsearch limits the speed that is allocated to recovery in order to avoid overloading the cluster. This setting can be updated to make the recovery faster or slower, depending on your requirements.
PUT _cluster/settings{"transient":{"indices.recovery.max_bytes_per_sec":"100mb"}}

Log Context
Log “Recovery failed” classname is GatewayService.java.
We extracted the following from Elasticsearch source code for those seeking an in-depth context :
} else { if (recovered.compareAndSet(false; true)) { threadPool.generic().execute(new AbstractRunnable() { Override public void onFailure(Exception e) { logger.warn("Recovery failed"; e); // we reset `recovered` in the listener don't reset it here otherwise there might be a race // that resets it to false while a new recover is already running? recoveryListener.onFailure("state recovery failed: " + e.getMessage()); }
Find & fix Elasticsearch problems
Opster AutoOps diagnoses & fixes issues in Elasticsearch based on analyzing hundreds of metrics.
Fix Your Cluster IssuesConnect in under 2 minutes
Matt Watson
CTO at Stackify