Why Cluster Allocation Explain API explains the allocation of the first unassigned shard?

Hi All,

Elasticsearch Version - 5.4.3

I have a cluster of only one node. I have created an index by using the following command:

curl -X PUT "node1:9200/index10" -H 'Content-Type: application/json' -d'

{
"settings" : {
"index" : {
"number_of_shards" : 5,
"number_of_replicas" : 1
}
}
}'

When I use the cat shards API command following is the output:
[root@node1 ~]# curl -X GET "node1:9200/_cat/shards"?v
index shard prirep state docs store ip node
index10 2 p STARTED 0 130b 10.0.4.67 node1
index10 2 r UNASSIGNED
index10 1 p STARTED 0 130b 10.0.4.67 node1
index10 1 r UNASSIGNED
index10 4 p STARTED 0 130b 10.0.4.67 node1
index10 4 r UNASSIGNED
index10 3 p STARTED 0 130b 10.0.4.67 node1
index10 3 r UNASSIGNED
index10 0 p STARTED 0 130b 10.0.4.67 node1
index10 0 r UNASSIGNED

It has "5" replicas shards in the "UNASSIGNED" state in the cluster. When cluster allocation explain API command is used following is the output:

[root@node1 ~]# curl -X GET "node1:9200/_cluster/allocation/explain"
{"index":"index10","shard":2,"primary":false,"current_state":"unassigned","unassigned_info":{"reason":"INDEX_CREATED","at":"2018-12-27T05:24:01.835Z","last_allocation_status":"no_attempt"},"can_allocate":"no","allocate_explanation":"cannot allocate because allocation is not permitted to any of the nodes","node_allocation_decisions":[{"node_id":"TRq-P0CKS5K0oZWFLIaBIA","node_name":"node1","transport_address":"10.0.4.67:9300","node_decision":"no","weight_ranking":1,"deciders":[{"decider":"same_shard","decision":"NO","explanation":"the shard cannot be allocated to the same node on which a copy of the shard already exists [[index10][2], node[TRq-P0CKS5K0oZWFLIaBIA], [P], s[STARTED], a[id=Hoist8tzT-W9y4VF0VOyHw]]"}]}]}[root@node1 ~]#

Explanation for only "UNASSIGNED" shard "2" is returned.

Instead, the explanation for every "UNASSIGNED" shard should have been returned here. What do you all think about it??

Regards
Nikhil Kapoor

The basic GET _cluster/allocation/explain API is intended to give a quick hint about why the cluster is not reporting green health, for which it is sufficient to describe any unassigned shard. It is quite common that there are many shards that are all unassigned for the same reason, and can all be fixed with one change. This is the case in your situation: since you only have one node no replicas can be assigned, and all unassigned shards will be reporting the shard cannot be allocated to the same node on which a copy of the shard already exists. Reporting all unassigned shards in this situation would be overwhelming and unhelpful.

If you want to diagnose a particular shard, you should use the more specific API:

GET /_cluster/allocation/explain
{
  "index": "myindex",
  "shard": 0,
  "primary": true
}

Thanks @DavidTurner for the reply. I understood your point.

Regards
Nikhil Kapoor

1 Like

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