# Why is replica shard in UNASSIGNED state if it exists on disk?

**URL:** <https://discuss.elastic.co/t/why-is-replica-shard-in-unassigned-state-if-it-exists-on-disk/118001>\
**Category:** Elasticsearch\
**Created:** [February 1, 2018, 10:50am UTC](https://discuss.elastic.co/t/why-is-replica-shard-in-unassigned-state-if-it-exists-on-disk/118001 "2018-02-01T10:50:50Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![YuWatanabe](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yuwatanabe/32/13259_2.png) [@YuWatanabe](https://discuss.elastic.co/u/YuWatanabe)\
**Post date:** [February 1, 2018, 10:50am UTC](https://discuss.elastic.co/t/why-is-replica-shard-in-unassigned-state-if-it-exists-on-disk/118001/1 "2018-02-01T10:50:50Z")

</div>

I would like to ask question regarding the shard allocation for [rolling restart](https://www.elastic.co/guide/en/elasticsearch/guide/2.x/_rolling_restarts.html),.

I am trying to figure out why shard allocation happens after following steps for rolling restart. I have done below test.

### Environment

1. 1 cluster with 2 master eligible nodes.
2. elasticsearch v6.1.1

### Steps

1.Create index

```
PUT test-indices
{
     "settings" : {
      "number_of_shards": 2,
      "number_of_replicas": 1
   }
}

```

2.Check which node each shard is located. Primary shard are spread on each node.

```
GET _cat/shards/test-indices?v
index shard prirep state docs store ip node
test-indices 1 r STARTED 0 233b 172.31.27.43 node2
test-indices 1 p STARTED 0 233b 172.31.27.43 node1
test-indices 0 p STARTED 0 233b 172.31.27.43 node2
test-indices 0 r STARTED 0 233b 172.31.27.43 node1

```

3.Disable shard reallocation and do sync flush.

```
PUT _cluster/settings
{
   "persistent" : {
      "cluster.routing.allocation.enable" : "none"
   }
}
 
POST _flush/synced

```

4.Shutdown node2  
5.Start node2

6.Check shards before re-enabling shard allocation. All replicas are **UNASSIGNED**. Even the replica for _shard 0_ .

```
GET _cat/shards/test-indices?v
index shard prirep state docs store ip node
test-indices 1 p STARTED 0 264b 172.31.27.43 node1
test-indices 1 r UNASSIGNED                         
test-indices 0 p STARTED 0 264b 172.31.27.43 node1
test-indices 0 r UNASSIGNED  

```

7 Also check the cluster state API and replica for _shard 0_ is **UNASSIGNED**

```
GET _cluster/state/routing_table/test-indices

{
  "cluster_name": "mycluster",
  "compressed_size_in_bytes": 15865,
  "routing_table": {
    "indices": {
      "test-indices": {
        "shards": {
          "0": [
            {
              "state": "STARTED",
              "primary": true,
              "node": "g-_vH5rwT-inWJuhHyjHcA",
              "relocating_node": null,
              "shard": 0,
              "index": "test-indices",
              "allocation_id": {
                "id": "QR-dWeL6ToGYShiHIROEDg"
              }
            },
            {
              "state": "UNASSIGNED",
              "primary": false,
              "node": null,
              "relocating_node": null,
              "shard": 0,
              "index": "test-indices",
              "recovery_source": {
                "type": "PEER"
              },
              "unassigned_info": {
                "reason": "NODE_LEFT",
                "at": "2018-02-01T10:40:13.350Z",
                "delayed": false,
                "details": "node_left[nB9E_CoCQmuC-Gjx4gvucA]",
                "allocation_status": "no_attempt"
              }
            }
          ],
          "1": [
            {
              "state": "STARTED",
              "primary": true,
              "node": "g-_vH5rwT-inWJuhHyjHcA",
              "relocating_node": null,
              "shard": 1,
              "index": "test-indices",
              "allocation_id": {
                "id": "5ZWVGFTgS0Gsg1R2Sf8iQQ"
              }
            },
            {
              "state": "UNASSIGNED",
              "primary": false,
              "node": null,
              "relocating_node": null,
              "shard": 1,
              "index": "test-indices",
              "recovery_source": {
                "type": "PEER"
              },
              "unassigned_info": {
                "reason": "NODE_LEFT",
                "at": "2018-02-01T10:40:13.350Z",
                "delayed": false,
                "details": "node_left[nB9E_CoCQmuC-Gjx4gvucA]",
                "allocation_status": "no_attempt"
              }
            }
          ]
        }
      }
    }
  }
}

```

It makes sense for replica shard on shard 1to be **UNASSIGNED** because it was promoted to **primary shard** , however, why is the replica shard for _shard 0_ **UNASSIGNED** if it exists on the disk ?

---

<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 1, 2018, 11:35pm UTC](https://discuss.elastic.co/t/why-is-replica-shard-in-unassigned-state-if-it-exists-on-disk/118001/2 "2018-02-01T23:35:41Z")

</div>

> [@YuWatanabe](#):
>
> 1 cluster with 2 master eligible nodes.

That's bad, see [Important Configuration Changes | Elasticsearch: The Definitive Guide [2.x] | Elastic](https://www.elastic.co/guide/en/elasticsearch/guide/2.x/important-configuration-changes.html#_minimum_master_nodes)

> [@YuWatanabe](#):
>
> It makes sense for replica shard on shard 1to be UNASSIGNED because it was promoted to primary shard, however, why is the replica shard for shard 0 UNASSIGNED if it exists on the disk ?

How did you enable allocation after the restart?

---

<div class="post-metadata">

**Author:** ![YuWatanabe](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yuwatanabe/32/13259_2.png) [@YuWatanabe](https://discuss.elastic.co/u/YuWatanabe)\
**Post date:** [February 2, 2018, 1:48am UTC](https://discuss.elastic.co/t/why-is-replica-shard-in-unassigned-state-if-it-exists-on-disk/118001/3 "2018-02-02T01:48:58Z")

</div>

@warkolm

Thank you for the reply.

> That's bad, see [Important Configuration Changes | Elasticsearch: The Definitive Guide [2.x] | Elastic](https://www.elastic.co/guide/en/elasticsearch/guide/2.x/important-configuration-changes.html#_minimum_master_nodes)

Yes. Thanks for mentioning.

> How did you enable allocation after the restart?

No . I have not enabled the allocation. _cluster.routing.allocation.enable_ is set as **none**.

---

<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 2, 2018, 5:08am UTC](https://discuss.elastic.co/t/why-is-replica-shard-in-unassigned-state-if-it-exists-on-disk/118001/4 "2018-02-02T05:08:08Z")

</div>

If allocation is still disabled, what you are seeing is expected.

---

<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 2, 2018, 5:08am UTC](https://discuss.elastic.co/t/why-is-replica-shard-in-unassigned-state-if-it-exists-on-disk/118001/5 "2018-03-02T05:08:48Z")

</div>

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