Australian cloud for business software — built and run in Sydney since 2002

NetLeverage
NetLeverage

Elasticsearch circuit_breaking_exception "[parent] Data too large, data for [<http_request>] would be [...]": find what is using the heap

Technical article
Troubleshooting

About this article: This article is reviewed against the cited sources. This is source research, not lab validation. Check the stated versions and your own requirements before making changes.

When Elasticsearch answers HTTP 429 with circuit_breaking_exception and [parent] Data too large, data for [<http_request>] would be [...], the node judged that the request would push its JVM heap past a safety limit, and refused it. The parent limit is 95% of the heap by default. Find which node is short of heap, then which breaker or request holds the memory, before you change a setting.

What the error means

Elastic's circuit breaker page says a breaker stops an operation that it estimates would exceed its limit, so the node does not run out of heap. A request that trips one gets an error with the 429 status. The page shows a body with type set to circuit_breaking_exception, a reason, bytes_wanted, bytes_limit and durability set to TRANSIENT.

In elastic/elasticsearch tag v8.19.0, HierarchyCircuitBreakerService.java builds the reason as [parent] Data too large, data for [, a label such as <http_request>, ] would be [, the bytes the node would use, ], which is larger than the limit of [, the limit, and, when real memory is tracked, , real usage: [ and ], new bytes reserved: [. A list of the breakers' usage follows.

In the page's own example the figures add up: real usage 120,182,112 plus new bytes reserved 3,666,526 is 123,848,638, which equals bytes_wanted. Our own reading: the would be figure is what the node already uses plus the request, and the limit is the parent limit.

The circuit breaker settings page defines the parent breaker: indices.breaker.total.use_real_memory is static and true by default, and indices.breaker.total.limit is the "Starting limit for overall parent breaker." It defaults to 95% of the JVM heap with real memory tracking, and to 70% without. The child breakers are separate: fielddata "Defaults to 40% of JVM heap", request "defaults to 60% of JVM heap", and in-flight requests default to 100%.

The error page recommends acting when usage "consistently exceeds 85%", which is below the 95% trip point.

Likely causes

Cause What you see How to confirm
The heap is under constant pressure Several nodes with high heap.percent, errors on many request types GET _cat/nodes?v=true&h=name,node*,heap*
Many shards on the node Memory grows with shard count, not with traffic The shard count per node; the pressure page says "Every shard uses memory."
Fielddata loaded on text fields The fielddata breaker's usage is high GET _nodes/stats/breaker
Large requests or heavy searches [<http_request>] or a search label in the message, large bytes_wanted The in-flight and request breakers in the stats; slow logs
A heap that is small for the node's data Pressure stays high even after the load drops Heap size set against the node's memory

Prove the cause before changing anything

All of these only read.

  1. Find which nodes are short of heap. The circuit breaker errors page uses this call:
GET _cat/nodes?v=true&h=name,node*,heap*
  1. Read each breaker's usage against its limit:
GET _nodes/stats/breaker
  1. Calculate JVM memory pressure the way the high memory pressure page does. The call returns the old pool's figures:
GET _nodes/stats?filter_path=nodes.*.jvm.mem.pools.old

The page gives the formula "JVM Memory Pressure = used_in_bytes / max_in_bytes". Elastic advises acting when a node's usage consistently exceeds 0.85 (85%).

  1. Look in elasticsearch.log on the affected node. The errors page says breaker errors are also written there, which helps when an automated process such as allocation trips the breaker. The same pressure page describes garbage collection lines of this shape, where the node spent more than half of 40 seconds collecting:
[gc][number] overhead, spent [21s] collecting in the last [40s]
  1. Note the label in the message. [<http_request>] means an incoming HTTP request. The log example on the errors page shows [<transport_request>]. Our own reading: that label is traffic between nodes, and a breaker that trips on automated work points at the node's own load, not at one client.

Fix

Elastic's pressure page lists ways to reduce memory pressure. Pick the one the proof steps support.

Fielddata is the large breaker

The errors page says fielddata on high-cardinality text fields can use a large amount of heap, so Elasticsearch disables it on text fields by default, and suggests a keyword field instead if you have enabled it. Our own reading: changing a field's mapping means reindexing it, which this page does not cover.

For a fielddata breaker that cannot be avoided, the errors page offers the clear cache API for fielddata and says: "This may disrupt any in-flight searches that use fielddata."

First save the current state, the breaker statistics, so that you can compare afterwards (add credentials and the https scheme if your cluster needs them):

curl -s localhost:9200/_nodes/stats/breaker > breaker-before.json

Risk: the first call below clears the fielddata cache on every index in the cluster, and the page gives no way to undo it. The page also lets you limit the request to an index (<target>) and to fields (fields), and the second call uses both. Searches that use fielddata can fail or slow down while the cache is loaded again, and the reload uses heap again.

Run only the one that applies. The first clears fielddata for the whole cluster, as the circuit breaker errors page shows:

POST _cache/clear?fielddata=true

The second limits it to one index and one field (the stats above do not name them, so find them first from the fields your mappings enable fielddata on):

POST /<index>/_cache/clear?fielddata=true&fields=<field>

There is nothing to restore after either. To check the result, run GET _nodes/stats/breaker again and compare the fielddata figures with breaker-before.json.

Too many shards or expensive searches

The pressure page says "Every shard uses memory" and that a small set of large shards generally uses fewer resources than many small ones, and points to its shard sizing guide. It also says "Expensive searches can use large amounts of memory", and lists the settings index.max_result_window, search.max_buckets, search.allow_expensive_queries and search.default_search_timeout as ways to limit them, with calls shown for the first three. Slow logs show which searches these are. These are cluster or index settings, and changing them changes what clients may ask for.

The heap itself is small

The Set JVM options page says: "Using the default sizing is recommended for most production environments." If you override it, it says the minimum and maximum heap must be the same and: "Set Xms and Xmx to no more than 50% of your total memory." Our own reading: a heap change is a JVM option on each node and needs that node to restart, so plan it as a rolling change. No commands are given here because the right size depends on the node's memory and role.

Example (illustrative): es01 has a 4GiB heap, which is 4,294,967,296 bytes. The default parent limit is 95%, so 4,294,967,296 x 0.95 = 4,080,218,931 bytes (3.8GiB). A bulk indexing request from app01 fails with [parent] Data too large, data for [<http_request>] would be [4093554432/3.8gb], which is larger than the limit of [4080218931/3.8gb], real usage: [4060000000/3.8gb], new bytes reserved: [33554432/32mb]. Check: 4,060,000,000 + 33,554,432 = 4,093,554,432, which is 13,335,501 bytes over the limit. _cat/nodes shows heap.percent above 94 on es01 for an hour, and _nodes/stats/breaker shows the fielddata breaker holding most of the tracked memory. The team clears the fielddata cache after saving the stats, then plans a keyword field to replace the text field that loaded it.

Confirm the fix

  1. heap.percent per node falls below 85 and stays there across a normal busy period.
  2. The request that failed completes without HTTP 429.
  3. _nodes/stats/breaker shows the breaker you identified well under its limit.
  4. The log has no new circuit breaker lines, and the garbage collection overhead lines have stopped.

What to watch afterwards

  • Track heap.percent and garbage collection overhead on each node. The page advises acting when pressure consistently exceeds 85%.
  • Watch the shard count per node as indices are added.
  • Check which fields have fielddata enabled.
  • Keep bulk requests to a size the nodes handle comfortably. The in-flight breaker counts the content length of active requests.

Risks and limits

  • These commands have not been run or lab-tested.
  • The clear cache page gives no way to undo it, and it only helps when fielddata was the cause.
  • A breaker is protecting the node. Raising a breaker limit would move the trip point toward an out-of-memory failure, so no limit increase is described here.
  • A heap change needs a restart of each node, with its own data and availability risk on a cluster.
  • The Elasticsearch 8.19 pages say the documentation is no longer updated, and the messages in newer releases may differ.

Sources