# 持久化任务异常：任务 [cluster:admin/persistent/assignment] 在 [5] 次尝试后未能将任务 [task_id_123] 分配给节点 [node-1]

- **ID:** `elasticsearch/persistent-task-assignment-failure`
- **领域:** elasticsearch
- **类别:** runtime_error
- **错误码:** `ES_PERSISTENT_TASK_ASSIGN_FAIL`
- **验证级别:** ai_generated
- **修复率:** 82%

## 根因

持久化任务（例如ILM、Rollup、Watcher）由于节点属性不匹配、资源限制或滚动重启期间集群拓扑变化而无法分配给任何可用节点。

## 版本兼容性

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

## 解决方案

1. ```
   Ensure all nodes have the required attributes set in `elasticsearch.yml` (e.g., `node.attr.rack: r1`) and restart nodes one by one, waiting for shard recovery after each restart.
   ```
2. ```
   Use the `_tasks` API to reassign the task manually: `POST _tasks/task_id_123/_cancel` then `POST _tasks/task_id_123/_retry`.
   ```
3. ```
   Check node resource availability (CPU, memory) and scale up or add more nodes to the cluster to free up capacity.
   ```

## 无效尝试

- **** — Forceful restart causes more assignment failures as tasks lose their target nodes and can't reassign mid-restart. (85% 失败率)
- **** — Retries don't fix the underlying node attribute or resource issue; they only delay the eventual failure. (75% 失败率)
- **** — This removes the task but loses its progress, and the task may be recreated by the system (e.g., ILM) causing the same error again. (90% 失败率)
