# How and why does elasticsearch enter a bad state on a long query

**URL:** <https://discuss.elastic.co/t/how-and-why-does-elasticsearch-enter-a-bad-state-on-a-long-query/75428>\
**Category:** Elasticsearch\
**Created:** [February 17, 2017, 3:35am UTC](https://discuss.elastic.co/t/how-and-why-does-elasticsearch-enter-a-bad-state-on-a-long-query/75428 "2017-02-17T03:35:33Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![arpan](https://avatars.discourse-cdn.com/v4/letter/a/e480ec/32.png) [@arpan](https://discuss.elastic.co/u/arpan)\
**Post date:** [February 17, 2017, 3:35am UTC](https://discuss.elastic.co/t/how-and-why-does-elasticsearch-enter-a-bad-state-on-a-long-query/75428/1 "2017-02-17T03:35:33Z")

</div>

So after running a really expensive query, elasticsearch got derped and a lot of the shards became unassigned.

They remained unassigned and I had to force assign these shards.

1. Does this result in data loss
2. if so, why does it result in data loss? Shouldn't elasticsearch have everything on disk for each shard. Why can't elasticsearch recover this?

---

<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 18, 2017, 10:18pm UTC](https://discuss.elastic.co/t/how-and-why-does-elasticsearch-enter-a-bad-state-on-a-long-query/75428/2 "2017-02-18T22:18:26Z")

</div>

What version are you on?

---

<div class="post-metadata">

**Author:** ![arpan](https://avatars.discourse-cdn.com/v4/letter/a/e480ec/32.png) [@arpan](https://discuss.elastic.co/u/arpan)\
**Post date:** [February 18, 2017, 11:32pm UTC](https://discuss.elastic.co/t/how-and-why-does-elasticsearch-enter-a-bad-state-on-a-long-query/75428/3 "2017-02-18T23:32:31Z")

</div>

version 2.4

---

<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 19, 2017, 7:07am UTC](https://discuss.elastic.co/t/how-and-why-does-elasticsearch-enter-a-bad-state-on-a-long-query/75428/4 "2017-02-19T07:07:59Z")

</div>

Force assigning primaries can cause data loss. Did you look into why the unassigned shards happened though - check your logs.

See [https://www.elastic.co/guide/en/elasticsearch/reference/2.4/cluster-reroute.html](https://www.elastic.co/guide/en/elasticsearch/reference/2.4/cluster-reroute.html) for more

---

<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:** [March 19, 2017, 7:08am UTC](https://discuss.elastic.co/t/how-and-why-does-elasticsearch-enter-a-bad-state-on-a-long-query/75428/5 "2017-03-19T07:08:02Z")

</div>

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