# How does Allocation of shards happens, when a node leaves cluster?

**URL:** <https://discuss.elastic.co/t/how-does-allocation-of-shards-happens-when-a-node-leaves-cluster/337960>\
**Category:** Elasticsearch\
**Created:** [July 9, 2023, 12:56pm UTC](https://discuss.elastic.co/t/how-does-allocation-of-shards-happens-when-a-node-leaves-cluster/337960 "2023-07-09T12:56:07Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shashank\_Agrawal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shashank_agrawal/32/122223_2.png) [@Shashank\_Agrawal](https://discuss.elastic.co/u/Shashank_Agrawal)\
**Post date:** [July 9, 2023, 12:56pm UTC](https://discuss.elastic.co/t/how-does-allocation-of-shards-happens-when-a-node-leaves-cluster/337960/1 "2023-07-09T12:56:07Z")

</div>

I want to know the exact procedure followed, for the allocation of shards on a node when the node leaves the cluster. Facts I know -  
1.) ES waits for sometime before the reassigning the shards.  
2.) For primary shards, a valid replica is searched for and then the replica is promoted to primary.

Questions I have  
1.) Which allocator specifically handles this scenario?(BalancedShardAllocator/GatewayAllocator or some other?)  
2.) What happens to replica shards, are they dropped or allocated to some other node..

Thanks.

---

<div class="post-metadata">

**Author:** ![DavidTurner](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/davidturner/32/22453_2.png) [@DavidTurner](https://discuss.elastic.co/u/DavidTurner)\
**Post date:** [July 9, 2023, 4:31pm UTC](https://discuss.elastic.co/t/how-does-allocation-of-shards-happens-when-a-node-leaves-cluster/337960/2 "2023-07-09T16:31:14Z")

</div>

1. GatewayAllocator
2. Assigned replicas are left where they are. Unassigned replicas are assigned normally.

---

<div class="post-metadata">

**Author:** ![Shashank\_Agrawal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shashank_agrawal/32/122223_2.png) [@Shashank\_Agrawal](https://discuss.elastic.co/u/Shashank_Agrawal)\
**Post date:** [July 9, 2023, 4:53pm UTC](https://discuss.elastic.co/t/how-does-allocation-of-shards-happens-when-a-node-leaves-cluster/337960/3 "2023-07-09T16:53:43Z")

</div>

Thanks for your kind reply,  
Can you provide me with link of some blog or post where I can read in depth about the allocation of shards in depth.

---

<div class="post-metadata">

**Author:** ![DavidTurner](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/davidturner/32/22453_2.png) [@DavidTurner](https://discuss.elastic.co/u/DavidTurner)\
**Post date:** [July 9, 2023, 5:09pm UTC](https://discuss.elastic.co/t/how-does-allocation-of-shards-happens-when-a-node-leaves-cluster/337960/4 "2023-07-09T17:09:33Z")

</div>

I don't think there is a blog post that goes into this level of detail. You'll need to read the source code.

---

<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:** [August 6, 2023, 5:10pm UTC](https://discuss.elastic.co/t/how-does-allocation-of-shards-happens-when-a-node-leaves-cluster/337960/5 "2023-08-06T17:10:00Z")

</div>

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