# PersistentTaskException: task [cluster:admin/persistent/assignment] failed to assign task [task_id_123] to node [node-1] after [5] attempts

- **ID:** `elasticsearch/persistent-task-assignment-failure`
- **Domain:** elasticsearch
- **Category:** runtime_error
- **Error Code:** `ES_PERSISTENT_TASK_ASSIGN_FAIL`
- **Verification:** ai_generated
- **Fix Rate:** 82%

## Root Cause

A persistent task (e.g., ILM, Rollup, Watcher) cannot be assigned to any available node because of node attribute mismatches, resource constraints, or cluster topology changes during rolling restart.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 7.17.0 | active | — | — |
| 8.11.0 | active | — | — |
| 8.12.0 | active | — | — |

## Workarounds

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.** (85% success)
   ```
   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`.** (75% success)
   ```
   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.** (80% success)
   ```
   Check node resource availability (CPU, memory) and scale up or add more nodes to the cluster to free up capacity.
   ```

## Dead Ends

- **** — Forceful restart causes more assignment failures as tasks lose their target nodes and can't reassign mid-restart. (85% fail)
- **** — Retries don't fix the underlying node attribute or resource issue; they only delay the eventual failure. (75% fail)
- **** — 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% fail)
