elasticsearch
system_error
ai_generated
partial
内存溢出:Java堆空间:无法为字段[user.id]分配字段数据
OutOfMemoryError: Java heap space: failed to allocate field data for field [user.id]
ID: elasticsearch/field-cache-too-large
72%修复率
87%置信度
1证据数
2023-09-01首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 7.17.0 | active | — | — | — |
| 8.10.0 | active | — | — | — |
| 8.12.1 | active | — | — | — |
根因分析
高基数字段(例如user.id)的字段数据缓存消耗过多堆内存,触发内存溢出错误。
English
The fielddata cache for a high-cardinality field (e.g., user.id) consumes too much heap memory, triggering an OutOfMemoryError.
官方文档
https://www.elastic.co/guide/en/elasticsearch/reference/current/fielddata.html解决方案
-
设置字段数据断路器限制:PUT _cluster/settings { "persistent": { "indices.breaker.fielddata.limit": "30%" } },同时设置字段数据缓存大小:PUT _cluster/settings { "persistent": { "indices.fielddata.cache.size": "20%" } } -
使用doc_values代替fielddata:重新索引字段并启用doc_values: true;对于keyword字段,doc_values默认启用,因此避免在没有doc_values的text字段上进行聚合
无效尝试
常见但无效的做法:
-
75% 失败
Larger heap may postpone OOM but fielddata can grow unbounded; eventually OOM recurs
-
80% 失败
Disabling fielddata breaks aggregations and sorting on that field; queries that depend on it will fail