Troubleshooting guide
Elasticsearch CircuitBreakingException: how to fix it
Elasticsearch rejected the request because completing it would have risked running out of heap. It is a safety mechanism: it failed one request to save the node.
3 min read10 sectionsUpdated
On this page
# Breaker usage, limits and trip counts
curl -s localhost:9200/_nodes/stats/breaker?pretty | grep -E '"(parent|fielddata|request)"|estimated_size"|limit_size"|tripped'
# Heap per node
curl -s 'localhost:9200/_cat/nodes?v&h=name,heap.percent,heap.max,ram.percent'
# Fielddata use by field
curl -s 'localhost:9200/_cat/fielddata?v'
# Shards per node
curl -s 'localhost:9200/_cat/allocation?v&h=node,shards'Fixes
Aggregate on keyword fields with doc values and not text. Reduce aggregation size, use a smaller time range, or use composite aggregations for paging. Keep heap at about half of RAM and below roughly 31 GB, so compressed object pointers stay enabled. Reduce the number of shards. Break bulk requests into 5 to 15 MB batches, and retry on 429 with backoff.
Fielddata explained
Doc values store column data on disk and are the default for keyword and numeric fields. text fields have none, so sorting or aggregating on them loads an in-memory structure called fielddata, which can be very large. It is disabled by default for that reason. If someone enabled it to make a dashboard work, that setting is the likely source of the trouble. The usual fix is a multi-field mapping with a .keyword subfield, and reindexing. Clear the cache in an emergency using POST _cache/clear?fielddata=true.
Catch it automatically
Alert on breaker trip counts and sustained heap above 85 percent using Elasticsearch monitoring. Log which query caused each 429, as a single dashboard often accounts for all of them.
Can I raise the breaker limits?
You can, but the risk is an out-of-memory crash, which is much worse than a rejected request.
Why not use a 64 GB heap?
Above about 31 GB the JVM loses compressed pointers, so usable capacity can actually fall.
Is 429 here retryable?
Yes, with backoff, once the memory pressure has eased.
Related reading
- 414 URI Too Long: causes and how to fix it: Fix 414 URI Too Long errors: redirect loops that grow the URL, huge query strings and large GET filters, with Nginx and Apache settings and better designs.
- 431 Request Header Fields Too Large: how to fix it: Fix 431 Request Header Fields Too Large: bloated cookies, Node.js header limits and localhost cookie build-up, with commands to measure real header size.
- .NET OutOfMemoryException: causes and how to fix it: Fix .NET System.OutOfMemoryException: use dotnet-counters and dotnet-gcdump, spot Large Object Heap fragmentation and set the right GC limits in containers.
- GC overhead limit exceeded in Java: how to fix it: Fix java.lang.OutOfMemoryError: GC overhead limit exceeded. Enable GC logs, take a heap dump, find what fills the heap and size the JVM for containers.
- Nginx "worker_connections are not enough": how to fix it: Fix Nginx worker_connections are not enough: why proxying uses two connections per client, how to size limits, raise descriptors and add upstream keepalive.
- PostgreSQL "too many clients already": how to fix it: Fix PostgreSQL FATAL: sorry, too many clients already. See who holds connections, stop leaks, add PgBouncer and size max_connections the right way.
Watch your own site and services with VitalRix
Uptime checks, APM, logs, real-user monitoring, alerts and status pages in one place. Every product has a free tier and no credit card is needed.