# Elasticsearch异常：分片分配后路由重试失败

- **ID:** `elasticsearch/transient-cluster-routing-error`
- **领域:** elasticsearch
- **类别:** runtime_error
- **验证级别:** ai_generated
- **修复率:** 75%

## 根因

当主节点在节点加入或离开后尝试重新分配分片时发生的临时集群路由故障，通常由于过时的集群状态或网络分区引起。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 7.17.0 | active | — | — |
| 8.11.0 | active | — | — |
| 8.12.0 | active | — | — |

## 解决方案

1. ```
   Force a cluster state update by temporarily disabling shard allocation, then re-enabling it: `PUT _cluster/settings {"transient": {"cluster.routing.allocation.enable": "none"}}` wait 30 seconds, then `PUT _cluster/settings {"transient": {"cluster.routing.allocation.enable": "all"}}`.
   ```
2. ```
   Clear the stale cluster state by running `POST /_cluster/reroute?retry_failed=true` to retry failed allocation commands.
   ```
3. ```
   If the error persists, take a snapshot of the cluster state with `POST /_snapshot/repo/backup` and then restart the master node with `--cluster.routing.allocation.disk.threshold_enabled=false` to bypass disk checks temporarily.
   ```

## 无效尝试

- **** — Restart does not resolve stale cluster state or network issues; the master will reattempt the same failed reroute. (85% 失败率)
- **** — Manual reroute bypasses cluster state validation, potentially causing duplicate shard copies or lost primary shards. (70% 失败率)
- **** — Higher concurrency may amplify the impact of stale routing decisions, leading to more failed reroute attempts. (60% 失败率)
