# ElasticsearchTimeoutException: 任务 [id:12345] 因超时在 [30000ms] 后被取消，等待完成时触发

- **ID:** `elasticsearch/task-cancellation-timeout`
- **领域:** elasticsearch
- **类别:** runtime_error
- **验证级别:** ai_generated
- **修复率:** 79%

## 根因

长时间运行的任务（如重新索引、强制合并、快照）超过了配置的超时或取消阈值，导致提前终止。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 7.15.0 | active | — | — |
| 7.17.15 | active | — | — |
| 8.6.0 | active | — | — |
| 8.10.0 | active | — | — |

## 解决方案

1. ```
   Increase the task timeout for the specific operation: POST _reindex?wait_for_completion=false&timeout=10m { "source": { "index": "old" }, "dest": { "index": "new" } }
   ```
2. ```
   Check and update cluster-level task cancellation settings: PUT _cluster/settings { "persistent": { "task.max_cancellation_timeout": "120s" } }
   ```
3. ```
   Retry the task with a smaller batch size or fewer shards to reduce execution time: POST _reindex { "source": { "index": "old", "size": 500 }, "dest": { "index": "new" } }
   ```

## 无效尝试

- **** — The error may be due to cluster-wide task cancellation settings (e.g., `task.max_cancellation_timeout`), not just the request timeout. Overriding locally may be ignored. (60% 失败率)
- **** — Task cancellation is recorded in cluster state, and restarting a single node does not reset the task manager on other nodes. The task will still be cancelled. (85% 失败率)
- **** — This is a security risk and may cause resource leaks. Also, it requires a node restart, which may not be feasible in production. (40% 失败率)
