Elasticsearch Cluster Turned Red: hs_err Logs, mmap, and 60,000 Shards
Notes on an Elasticsearch cluster incident:
the analysis, the troubleshooting, and the recovery.
🕰️ Version note: This post was written in 2025, against an Elasticsearch 7.16.2 cluster. The technology moves fast — read it alongside the version you actually run.
Background
In the morning a colleague started a group chat to report write timeouts on an ES cluster they use. Checking the cluster health showed it was already red.
- This was a 3 × 8-core, 32 GB cluster (JVM heap configured at 16 GB)
- At the time of the failure the cluster held 5000 indices, each with 6 shards and 1 replica — that is, 12 shards per index
- The shard count had already reached
6w(60,000), not counting Elasticsearch's own system indices
- The shard count had already reached
- The cluster instances had been restarted
- Data volume was roughly 480 GB
Does any of this feel familiar?
=> Elasticsearch Cluster Lost Its Master: Thread Pools, Packet Capture, and 60,000 Shards
We contacted the owning service team right away to delete historical data; they confirmed that the 2022 and 2023 data could be deleted.
Handling
Speeding up recovery
After the team kicked off the batch deletions, I first raised the cluster's recovery-related settings:
1 | PUT /_cluster/settings |
On the recovery speed settings: https://elastic.ac.cn/guide/en/elasticsearch/reference/8.17/recovery.html
During recovery, the ES instances kept emitting this WARN log:
1 | Unable to acquire permit to use snapshot files during recovery, |
Checking the cluster settings:
1 | GET /_cluster/settings?include_defaults=true |
So we ignored it for the time being. After recovery finished, the log stopped appearing.
Investigation
I picked one ES node and downloaded its logs from the last few days to work out why the instance had exited.
Right before the exit, the logs were full of this exception:
1 | this may be caused by lack of enough unfragmented virtual address space |
max_map_count looked fine:
1 | [root@prd-jiankunking-notify-es-3: /app/es/data/nodes/0]# ulimit -m |
262144 is the minimum value Elasticsearch 7.16.2 prints on startup.
Now the logs at the moment the instance exited:
1 | OpenJDK 64-Bit Server VM warning: INFO: os::commit_memory(0x00007fe4d805c000, 65536, 1) failed; error='Not enough space' (errno=12) |
Then the contents of logs/hs_err_pid7.log:
1 | # |
Conclusion
By this point it was clear: the Elasticsearch process exited because it could not allocate native memory (mmap) — there was not enough memory.
After the data was deleted, via
1 | GET /_cat/health?v |
we saw active_shards_percent recover to 100%, but 19 shards were still unassigned.
Checking why they had not been allocated:
1 | GET /_cluster/allocation/explain |
The response:
1 | { |
Re-triggering the allocation manually:
1 | POST /_cluster/reroute?retry_failed=true |
The cluster health went red -> yellow -> green.
After the owning service team cleaned up the historical data, the cluster:
- Shard count dropped to 40,000
- Data volume dropped to 335.3 GB
This article is the English edition of a post originally published in Chinese.