The gateway.recover_after_time
setting in Elasticsearch controls the maximum amount of time to wait for recovery of local shards during cluster startup before allowing the cluster to form.
Description
- Default value: 5 minutes
- Possible values: Time value (e.g., 10m, 1h)
- Recommendation: Adjust based on your cluster size and recovery requirements
This setting works in conjunction with gateway.recover_after_nodes
and gateway.expected_nodes
. It defines a time window during which Elasticsearch will wait for the specified number of nodes to join the cluster before starting the recovery process.
Example
To change the gateway.recover_after_time
setting using the cluster settings API:
PUT /_cluster/settings
{
"persistent": {
"gateway.recover_after_time": "10m"
}
}
This change increases the recovery wait time to 10 minutes, which can be useful for larger clusters that need more time for nodes to join during startup.
Common Issues and Misuses
- Setting the value too low may result in incomplete cluster formation if nodes take longer to join.
- Setting the value too high can unnecessarily delay cluster startup when all nodes are actually available.
Do's and Don'ts
- Do: Adjust this setting in conjunction with
gateway.recover_after_nodes
andgateway.expected_nodes
for optimal cluster startup behavior. - Do: Monitor cluster startup times and adjust the value based on your specific environment.
- Don't: Set this value excessively high, as it can lead to prolonged downtime during cluster restarts.
- Don't: Ignore this setting when scaling your cluster, as larger clusters may require longer recovery times.
Frequently Asked Questions
Q: How does gateway.recover_after_time interact with other recovery settings?
A: It works together with gateway.recover_after_nodes
and gateway.expected_nodes
. The cluster will wait for either the specified number of nodes to join or the recover_after_time
to elapse, whichever comes first.
Q: Can changing this setting impact cluster stability?
A: Yes, if set too low, it might cause the cluster to form before all nodes have joined, potentially leading to unbalanced shard distribution. If set too high, it can unnecessarily delay cluster formation.
Q: Is it safe to change this setting on a running cluster?
A: Yes, you can change it dynamically using the cluster settings API. However, the new value will only take effect during the next cluster restart.
Q: How can I determine the optimal value for my cluster?
A: Monitor your cluster startup times and node join behavior. Set the value slightly higher than the typical time it takes for all your nodes to join the cluster during a normal restart.
Q: Does this setting affect rolling restarts?
A: No, this setting primarily affects full cluster restarts. During rolling restarts, nodes join an already formed cluster, so this setting doesn't come into play.