# Circuit breaker always trips

**URL:** https://discuss.elastic.co/t/circuit-breaker-always-trips/109067
**Category:** Elasticsearch
**Created:** [November 24, 2017, 5:29pm UTC](https://discuss.elastic.co/t/circuit-breaker-always-trips/109067 "2017-11-24T17:29:23Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![Attila\_Nagy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/attila_nagy/32/46906_2.png) [@Attila\_Nagy](https://discuss.elastic.co/u/Attila_Nagy)
#### Post date: [November 24, 2017, 5:29pm UTC](https://discuss.elastic.co/t/circuit-breaker-always-trips/109067/1 "2017-11-24T17:29:23Z")

</div>

I have a cluster of 40 nodes. Today Elasticsearch started to return circuit breaker exceptions for all queries on two given nodes.  
Even for this:

```auto
$ curl -s 'http://localhost:9200/'

```

```auto
{
   "error":{
      "root_cause":[
         {
            "type":"circuit_breaking_exception",
            "reason":"[parent] Data too large, data for [<http_request>] would be [13610582016/12.6gb], which is larger than the limit of [11885484441/11gb]",
            "bytes_wanted":13610582016,
            "bytes_limit":11885484441
         }
      ],
      "type":"circuit_breaking_exception",
      "reason":"[parent] Data too large, data for [<http_request>] would be [13610582016/12.6gb], which is larger than the limit of [11885484441/11gb]",
      "bytes_wanted":13610582016,
      "bytes_limit":11885484441
   },
   "status":503
}

```

How can I figure out what is the problem? Should the above log say how much memory that given query needs?  
And if it shows that, what's going on? How can the above (and all other queries to those nodes) die with this error?  
I see that the request breakers trip on those nodes. After cluster restart the same continues in some minutes.

If we reach the above situation, the node remains in the cluster but every operation to it fails.

Elasticsearch 5.6.4.

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [November 24, 2017, 5:48pm UTC](https://discuss.elastic.co/t/circuit-breaker-always-trips/109067/2 "2017-11-24T17:48:24Z")

</div>

That looks weird.

Could you share your mappings?

---

<div class="post-metadata">

### Author: ![Attila\_Nagy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/attila_nagy/32/46906_2.png) [@Attila\_Nagy](https://discuss.elastic.co/u/Attila_Nagy)
#### Post date: [November 24, 2017, 5:57pm UTC](https://discuss.elastic.co/t/circuit-breaker-always-trips/109067/3 "2017-11-24T17:57:54Z")

</div>

I've sent it in a private message.  
BTW, yesterday we started to use some new indexes with bigger docs (updated with scripts in bulk and returning the source in the bulk call), otherwise I don't know anything which has changed.  
But I've already disabled that code and the problem still persists.  
Bigger here means an enabled: false object and some (1-6) keys in the following structure:

> <https://gist.github.com/bra-fsn/5997a86d869467d595dc14f1f05e4d27>

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [November 24, 2017, 9:55pm UTC](https://discuss.elastic.co/t/circuit-breaker-always-trips/109067/4 "2017-11-24T21:55:15Z")

</div>

I don’t understand why the circuit breaker complains with a match\_all query.

@dakrone does this reminds you anything?

---

<div class="post-metadata">

### Author: ![Attila\_Nagy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/attila_nagy/32/46906_2.png) [@Attila\_Nagy](https://discuss.elastic.co/u/Attila_Nagy)
#### Post date: [November 24, 2017, 10:01pm UTC](https://discuss.elastic.co/t/circuit-breaker-always-trips/109067/5 "2017-11-24T22:01:32Z")

</div>

I've started to graph estimated breaker size:  
 ![image](https://us1.discourse-cdn.com/elastic/original/3X/c/d/cdf3c8612acc5805646831626091fe992368913f.png)  
According to the logs, the first entries are -so far- a repeated aggregation, which may be right, or not, I don't yet know:  
[2017-11-24T21:52:55,425][WARN][o.e.i.b.request] [request] New used memory 10664646024 [9.9gb] for data of [\<agg [messagesByFolders]\>] would be larger than configured breaker: 10213706956 [9.5gb], breaking  
[2017-11-24T21:52:56,049][WARN][o.e.i.b.request] [request] New used memory 11342156800 [10.5gb] for data of [\<agg [messagesByFolders]\>] would be larger than configured breaker: 10213706956 [9.5gb], breaking  
[2017-11-24T21:52:56,666][WARN][o.e.i.b.request] [request] New used memory 11342156800 [10.5gb] for data of [\<agg [messagesByFolders]\>] would be larger than configured breaker: 10213706956 [9.5gb], breaking  
[2017-11-24T21:52:57,824][WARN][o.e.i.b.request] [request] New used memory 11342156800 [10.5gb] for data of [\<agg [messagesByFolders]\>] would be larger than configured breaker: 10213706956 [9.5gb], breaking

But what I don't understand is why does it affect even a simple root query ([http://localhost:9200/](http://localhost:9200/)). Shouldn't breakers stop just the query which is over the allowed size? Why the estimated size grows linearly and denies all subsequent requests on the affected node(s) after some minutes?

Do I misunderstand the concept of breakers entirely?

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [November 24, 2017, 10:28pm UTC](https://discuss.elastic.co/t/circuit-breaker-always-trips/109067/6 "2017-11-24T22:28:19Z")

</div>

I don’t know.

But for sure, I saw in you mappings that you disabled doc\_values. Was there a reason for doing so?

---

<div class="post-metadata">

### Author: ![Attila\_Nagy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/attila_nagy/32/46906_2.png) [@Attila\_Nagy](https://discuss.elastic.co/u/Attila_Nagy)
#### Post date: [November 24, 2017, 10:30pm UTC](https://discuss.elastic.co/t/circuit-breaker-always-trips/109067/7 "2017-11-24T22:30:53Z")

</div>

Nothing more than saving space where we don't use them.

---

<div class="post-metadata">

### Author: ![Attila\_Nagy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/attila_nagy/32/46906_2.png) [@Attila\_Nagy](https://discuss.elastic.co/u/Attila_Nagy)
#### Post date: [November 25, 2017, 12:51am UTC](https://discuss.elastic.co/t/circuit-breaker-always-trips/109067/8 "2017-11-25T00:51:53Z")

</div>

OK, so the questions seem to be:

1. why does the request breakers' size constantly grow until it hits the limit and no query can get in? it's not a single query, but a bunch of queries (hence the steep curve on the graph, but it's not like a dirac delta).  
"breakers" : {  
"request" : {  
"limit\_size\_in\_bytes" : 10187558092,  
"limit\_size" : "9.4gb",  
"estimated\_size\_in\_bytes" : 11343200256,  
"estimated\_size" : "10.5gb",  
"overhead" : 1.0,  
"tripped" : 250  
},
2. how could I see what queries account for these values?
3. how can it be that the JVM heap size (reported by elastic) doesn't show this increased memory usage? (maybe a counter leak, it doesn't get decremented after a query finishes?)
4. why is this localized to two nodes only (i will try to narrow it down to given indices, but it seems it happens only where the primary and replica shards of a given index are)

Also I think that the log/returned error (currently: [2017-11-24T21:52:55,425][WARN][o.e.i.b.request] [request] New used memory 10664646024 [9.9gb] for data of [\<agg [messagesByFolders]\>] would be larger than configured breaker: 10213706956 [9.5gb], breaking) should also include that individual query's estimated memory requirement, so if the estimated size grows by gigabytes every seconds, it may be traced better from the logs.

BTW, this is very similar to [https://github.com/elastic/elasticsearch/issues/26943](https://github.com/elastic/elasticsearch/issues/26943), except that I have a very rapid explosion in request breaker's size. (and doesn't have any plugins apart from icu)

---

<div class="post-metadata">

### Author: ![Attila\_Nagy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/attila_nagy/32/46906_2.png) [@Attila\_Nagy](https://discuss.elastic.co/u/Attila_Nagy)
#### Post date: [November 25, 2017, 8:30am UTC](https://discuss.elastic.co/t/circuit-breaker-always-trips/109067/9 "2017-11-25T08:30:52Z")

</div>

OK, I've raised the breakers' limit to 2^63-1 bytes, it made the cluster stable.  
 ![image](https://us1.discourse-cdn.com/elastic/original/3X/e/a/ea2dd402241025538c2bb232212a84dcb50365d8.png)  
So it seems this is a counter bug/leak, obviously no node can use 170 GiB of heap.

And I think I found the root cause.  
Opened issue:

> <https://github.com/elastic/elasticsearch/issues/27525>

---

<div class="post-metadata">

### Author: ![dakrone](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dakrone/32/23351_2.png) [@dakrone](https://discuss.elastic.co/u/dakrone)
#### Post date: [November 29, 2017, 3:19am UTC](https://discuss.elastic.co/t/circuit-breaker-always-trips/109067/10 "2017-11-29T03:19:09Z")

</div>

Yep, that's definitely it. It's an issue where the stream is not closed, so the breaker isn't decrementing the accounting by the number of bytes. There's a PR open now to fix this.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [December 27, 2017, 3:19am UTC](https://discuss.elastic.co/t/circuit-breaker-always-trips/109067/11 "2017-12-27T03:19:14Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
