# ElasticsearchTimeoutException: task [id:12345] cancelled with reason [timeout] after [30000ms] while waiting for completion

- **ID:** `elasticsearch/task-cancellation-timeout`
- **Domain:** elasticsearch
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 79%

## Root Cause

A long-running task (e.g., reindex, force merge, snapshot) exceeded the configured timeout or cancellation threshold, leading to premature termination.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 7.15.0 | active | — | — |
| 7.17.15 | active | — | — |
| 8.6.0 | active | — | — |
| 8.10.0 | active | — | — |

## Workarounds

1. **Increase the task timeout for the specific operation: POST _reindex?wait_for_completion=false&timeout=10m { "source": { "index": "old" }, "dest": { "index": "new" } }** (78% success)
   ```
   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" } }** (82% success)
   ```
   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" } }** (75% success)
   ```
   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" } }
   ```

## Dead Ends

- **** — 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% fail)
- **** — 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% fail)
- **** — This is a security risk and may cause resource leaks. Also, it requires a node restart, which may not be feasible in production. (40% fail)
