{
  "id": "elasticsearch/field-cache-eviction-oom",
  "signature": "OutOfMemoryError: Java heap space (field cache eviction) while loading fielddata for field [user.name]",
  "signature_zh": "OutOfMemoryError：Java 堆空间（字段缓存驱逐）在加载字段 [user.name] 的字段数据时",
  "regex": "OutOfMemoryError.*Java heap space.*field cache eviction.*loading fielddata for field",
  "domain": "elasticsearch",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "The fielddata cache for aggregations on text fields consumes excessive heap memory, leading to an OutOfMemoryError during cache eviction or loading.",
  "root_cause_type": "generic",
  "root_cause_zh": "用于文本字段聚合的字段数据缓存消耗过多堆内存，导致在缓存驱逐或加载期间发生 OutOfMemoryError。",
  "versions": [
    {
      "version": "Elasticsearch 7.10.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Elasticsearch 8.9.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Elasticsearch 8.14.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "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.",
      "fail_rate": 0.65,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "This can cause severe performance degradation because every aggregation will reload fielddata from disk, leading to high latency and potential OOM from concurrent loads.",
      "fail_rate": 0.75,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "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}}}`",
      "success_rate": 0.8,
      "how": "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}}}`",
      "condition": "",
      "sources": []
    },
    {
      "action": "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.",
      "success_rate": 0.76,
      "how": "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.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "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}}}`",
    "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."
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://www.elastic.co/guide/en/elasticsearch/reference/current/circuit-breaker.html#fielddata-circuit-breaker",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.83,
  "fix_success_rate": 0.74,
  "resolvable": "partial",
  "first_seen": "2024-04-01",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}