elasticsearch runtime_error ai_generated partial

OutOfMemoryError:Java 堆空间(字段缓存驱逐)在加载字段 [user.name] 的字段数据时

OutOfMemoryError: Java heap space (field cache eviction) while loading fielddata for field [user.name]

ID: elasticsearch/field-cache-eviction-oom

其他格式: JSON · Markdown 中文 · English
74%修复率
83%置信度
1证据数
2024-04-01首次发现

版本兼容性

版本状态引入弃用备注
Elasticsearch 7.10.0 active — — —
Elasticsearch 8.9.0 active — — —
Elasticsearch 8.14.0 active — — —

根因分析

用于文本字段聚合的字段数据缓存消耗过多堆内存,导致在缓存驱逐或加载期间发生 OutOfMemoryError。

English

The fielddata cache for aggregations on text fields consumes excessive heap memory, leading to an OutOfMemoryError during cache eviction or loading.

generic

官方文档

https://www.elastic.co/guide/en/elasticsearch/reference/current/circuit-breaker.html#fielddata-circuit-breaker

解决方案

  1. Enable `eager_fielddata` on the field mapping to preload fielddata at index time, reducing peak memory usage during queries. Update mapping: `PUT my_index/_mapping {"properties": {"user.name": {"type": "text", "fielddata": true, "eager_fielddata": true}}}`
  2. Limit the fielddata cache size and set a circuit breaker. Configure in `elasticsearch.yml`: `indices.fielddata.cache.size: 20%` and `indices.breaker.fielddata.limit: 40%`. Then restart the node.

无效尝试

常见但无效的做法:

  1. 65% 失败

    This only postpones the OOM error; large aggregations on high-cardinality text fields can still exhaust memory, and large heaps can cause longer GC pauses.

  2. 75% 失败

    This can cause severe performance degradation because every aggregation will reload fielddata from disk, leading to high latency and potential OOM from concurrent loads.