TASK_CANCELLED elasticsearch runtime_error ai_generated true

TaskCancellationException: 任务[id:12345]因超时被取消,等待完成中

TaskCancellationException: task [id:12345] cancelled with reason [timeout] while waiting for completion

ID: elasticsearch/task-cancellation-exception

其他格式: JSON · Markdown 中文 · English
80%修复率
85%置信度
1证据数
2024-06-15首次发现

版本兼容性

版本状态引入弃用备注
Elasticsearch 7.17 active
Elasticsearch 8.5 active
Elasticsearch 8.10 active

根因分析

长时间运行的任务(如重新索引、快照)超过了配置的超时时间,被集群强制取消。

English

A long-running task (e.g., reindex, snapshot) exceeded the configured timeout and was forcibly cancelled by the cluster.

generic

官方文档

https://www.elastic.co/guide/en/elasticsearch/reference/current/tasks.html

解决方案

  1. 通过API增加特定任务的超时时间,例如:`POST _tasks/cancel?actions=cluster:admin/reindex&timeout=2h`
  2. 通过减少批量大小优化任务:对于重新索引,设置`{"source": {"size": 500}, "dest": {"index": "new_index"}}`
  3. 如果任务涉及大量聚合,增加`search.max_buckets`和`search.max_buckets_per_cluster`

无效尝试

常见但无效的做法:

  1. Increasing task timeout in elasticsearch.yml (e.g., `task.timeout: 60m`) without analyzing actual task duration 70% 失败

    This may mask underlying performance issues (e.g., slow disk, insufficient memory) and cause cascading failures.

  2. Restarting the cluster to clear all tasks 80% 失败

    Restarting drops all ongoing tasks, but the error will reoccur if the root cause (e.g., slow shard recovery) is not addressed.

  3. Setting `task.timeout: 0` to disable timeout 90% 失败

    This can lead to indefinite task hangs and resource exhaustion, as the cluster will never cancel stuck tasks.