# Can a heavy query cause index corruption?

**URL:** <https://discuss.elastic.co/t/can-a-heavy-query-cause-index-corruption/41799>\
**Category:** Elasticsearch\
**Created:** [February 15, 2016, 2:53pm UTC](https://discuss.elastic.co/t/can-a-heavy-query-cause-index-corruption/41799 "2016-02-15T14:53:43Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![alienmind](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alienmind/32/10799_2.png) [@alienmind](https://discuss.elastic.co/u/alienmind)\
**Post date:** [February 15, 2016, 2:53pm UTC](https://discuss.elastic.co/t/can-a-heavy-query-cause-index-corruption/41799/1 "2016-02-15T14:53:43Z")

</div>

Hi

I've been running some aggresive tests (on purposely reduced hardware specs) and faced the following issue. My cluster is:

- ES 2.2.0 on CentOS 6.7
- 4x nodes with 4GB RAM (2GB for the JVM), 8 cores.
- Extended the bulk thread queue size from 50 to 1000
- 20x clients running on the REST api, sending bulk indexing requests with 1000 records each

Then, I've run a few heavy aggregates. The idea is to force ES to retrieve the data from disk (avoiding FS cache whatsoever) to measure some sort of "worst case scenario"

One of the nodes crashed due to OutOfMemory exception during one of the aggregates.\*\* This caused corruption on 100% shards of that node\*\*! Now the cluster is relocating shards but it's painfully slow.

I find hard to believe that a query - as heavy as it is - can cause full corruption of a node. This would be a no-go for production in the project I'm working at.

Is there a way to ensure that the queries memory does not take down the full node? I've been wondering if lowering the three available circuit breakers so they don't sum more than 100% will help ([https://www.elastic.co/guide/en/elasticsearch/guide/current/\_limiting\_memory\_usage.html](https://www.elastic.co/guide/en/elasticsearch/guide/current/_limiting_memory_usage.html)) :

But I find this really annoying - lowering these limits "just in case" doesn't seem reasonable.

Any other ideas / tips?

The full trace can be found here: [http://pastie.org/pastes/10722735/text?key=8jrwowaumantpoqjvctq](http://pastie.org/pastes/10722735/text?key=8jrwowaumantpoqjvctq)

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [February 15, 2016, 3:50pm UTC](https://discuss.elastic.co/t/can-a-heavy-query-cause-index-corruption/41799/2 "2016-02-15T15:50:58Z")

</div>

2GB of heap isn't very much at all ☹

---

<div class="post-metadata">

**Author:** ![alienmind](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alienmind/32/10799_2.png) [@alienmind](https://discuss.elastic.co/u/alienmind)\
**Post date:** [February 15, 2016, 4:11pm UTC](https://discuss.elastic.co/t/can-a-heavy-query-cause-index-corruption/41799/3 "2016-02-15T16:11:56Z")

</div>

Yes, it is not, on purpose. But it gives an idea of what will happen on production when I will have 16GB of heaps and the query is 8x more complex (I've queried 1 month of data and I expect to be able to do the same over 1 year)

---

<div class="post-metadata">

**Author:** ![mikemccand](https://avatars.discourse-cdn.com/v4/letter/m/f04885/32.png) [@mikemccand](https://discuss.elastic.co/u/mikemccand)\
**Post date:** [February 15, 2016, 4:15pm UTC](https://discuss.elastic.co/t/can-a-heavy-query-cause-index-corruption/41799/4 "2016-02-15T16:15:43Z")

</div>

OutOfMemoryError should never result in corruption.

Can you share the full stack traces of both the original OOME you hit and the resulting corruption exceptions?

---

<div class="post-metadata">

**Author:** ![alienmind](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alienmind/32/10799_2.png) [@alienmind](https://discuss.elastic.co/u/alienmind)\
**Post date:** [February 15, 2016, 4:29pm UTC](https://discuss.elastic.co/t/can-a-heavy-query-cause-index-corruption/41799/5 "2016-02-15T16:29:13Z")

</div>

The stack trace is on post #1 (pastie)

---

<div class="post-metadata">

**Author:** ![mikemccand](https://avatars.discourse-cdn.com/v4/letter/m/f04885/32.png) [@mikemccand](https://discuss.elastic.co/u/mikemccand)\
**Post date:** [February 15, 2016, 9:44pm UTC](https://discuss.elastic.co/t/can-a-heavy-query-cause-index-corruption/41799/6 "2016-02-15T21:44:01Z")

</div>

> The stack trace is on post #1 (pastie)

Woops, sorry, I missed that.

OK I looked at the exceptions, and this is not actually index corruption.

Rather, ES has decided that this shard is in an unknown state ("failed engine"), no longer in sync with its peers, and therefore must hard-close it and recopy the shard to sync up again, which is what you see happening.

I think you do need to use the circuit breakers to guard against 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:** [July 5, 2017, 11:16pm UTC](https://discuss.elastic.co/t/can-a-heavy-query-cause-index-corruption/41799/7 "2017-07-05T23:16:13Z")

</div>


