# Primary shard not available

**URL:** <https://discuss.elastic.co/t/primary-shard-not-available/161687>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-monitoring\
**Created:** [December 20, 2018, 11:32am UTC](https://discuss.elastic.co/t/primary-shard-not-available/161687 "2018-12-20T11:32:07Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![amitavmohanty01](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/amitavmohanty01/32/58017_2.png) [@amitavmohanty01](https://discuss.elastic.co/u/amitavmohanty01)\
**Post date:** [December 20, 2018, 11:32am UTC](https://discuss.elastic.co/t/primary-shard-not-available/161687/1 "2018-12-20T11:32:07Z")

</div>

Hi

I am facing issues because the primary shard is not available. What could be the reason for it? Please suggest.

Caused by: org.elasticsearch.action.UnavailableShardsException: [.monitoring-kibana-6-2018.12.20][0] primary shard is not active  
Timeout: [1m], request: [BulkShardRequest [[.monitoring-kibana-6-2018.12.20][0]] containing [index {[.monitoring-kibana-6-2018.12  
.20][doc][KbugymcBNIueI7r1ErSY], source[{"cluster\_uuid":"lqoa3HJhRPyUAQUkLgFeqw","timestamp":"2018-12-20T07:59:07.413Z","interval  
_ms":10000,"type":"kibana\_stats","source\_node":{"uuid":"CiXHakymT\_6VN-KMuIKsfQ","host":"myhost","tran  
sport\_address":"10.240.0.14:9401","ip":"10.240.0.14","name":"elkkibana01.pod","timestamp":"2018-12-20T07:59:07.413Z"},"kibana_  
stats":{"kibana":{"uuid":"1a54c2b0-78e8-4d76-9dc3-6dd93e9a8f67","name":"myhost","index":".kibana","ho  
st":"0","transport\_address":"0:9018","version":"6.4.2","snapshot":false,"status":"green"},"usage":{"xpack":{"reporting":{"availab  
le":true,"enabled":true,"browser\_type":"phantom","\_all":0,"csv":{"available":true,"total":0},"printable\_pdf":{"available":false,"  
total":0},"status":{},"lastDay":{"\_all":0,"csv":{"available":true,"total":0},"printable\_pdf":{"available":false,"total":0},"statu  
s":{}},"last7Days":{"\_all":0,"csv":{"available":true,"total":0},"printable\_pdf":{"available":false,"total":0},"status":{}}}}}}}]}  
]]  
at org.elasticsearch.action.support.replication.TransportReplicationAction$ReroutePhase.retryBecauseUnavailable(Transport  
ReplicationAction.java:927) ~[elasticsearch-6.4.2.jar:6.4.2]  
at org.elasticsearch.action.support.replication.TransportReplicationAction$ReroutePhase.retryIfUnavailable(TransportRepli  
cationAction.java:773) ~[elasticsearch-6.4.2.jar:6.4.2]  
at org.elasticsearch.action.support.replication.TransportReplicationAction$ReroutePhase.doRun(TransportReplicationAction.java:726) ~[elasticsearch-6.4.2.jar:6.4.2]  
at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37) ~[elasticsearch-6.4.2.jar:6.4.2]  
at org.elasticsearch.action.support.replication.TransportReplicationAction$ReroutePhase$2.onTimeout(TransportReplicationAction.java:887) ~[elasticsearch-6.4.2.jar:6.4.2]  
at org.elasticsearch.cluster.ClusterStateObserver$ContextPreservingListener.onTimeout(ClusterStateObserver.java:317) ~[elasticsearch-6.4.2.jar:6.4.2]  
at org.elasticsearch.cluster.ClusterStateObserver$ObserverClusterStateListener.onTimeout(ClusterStateObserver.java:244) ~[elasticsearch-6.4.2.jar:6.4.2]  
at org.elasticsearch.cluster.service.ClusterApplierService$NotifyTimeout.run(ClusterApplierService.java:573) ~[elasticsearch-6.4.2.jar:6.4.2]  
at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingRunnable.run(ThreadContext.java:624) ~[elasticsearch-6.4.2.jar:6.4.2]  
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) ~[?:1.8.0\_181]  
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) ~[?:1.8.0\_181]  
... 1 more

Regards,

---

<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:** [December 20, 2018, 1:55pm UTC](https://discuss.elastic.co/t/primary-shard-not-available/161687/2 "2018-12-20T13:55:13Z")

</div>

This can be answered with the [allocation explain API](https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-allocation-explain.html):

```nohighlight
GET /_cluster/allocation/explain
{
  "index": ".monitoring-kibana-6-2018.12.20",
  "shard": 0,
  "primary": true
}

```

If the result of that call is unclear, please share it here for further help.

---

<div class="post-metadata">

**Author:** ![amitavmohanty01](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/amitavmohanty01/32/58017_2.png) [@amitavmohanty01](https://discuss.elastic.co/u/amitavmohanty01)\
**Post date:** [December 20, 2018, 3:33pm UTC](https://discuss.elastic.co/t/primary-shard-not-available/161687/3 "2018-12-20T15:33:39Z")

</div>

Thank you for the reply. The explanation I got is as follows:

> "reached the limit of ongoing initial primary recoveries [4], cluster setting [cluster.routing.allocation.node\_initial\_primaries\_recoveries=4]"

I am considering increasing the recoveries count. What would be the repercussions of it?

---

<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:** [December 20, 2018, 3:42pm UTC](https://discuss.elastic.co/t/primary-shard-not-available/161687/4 "2018-12-20T15:42:50Z")

</div>

> [@amitavmohanty01](#):
>
> What would be the repercussions of it?

Running too many recoveries in parallel can result in some or all of them timing out and failing, and can consume too many cluster resources such as bandwidth.

However, primary recoveries are normally quite quick, so I'm a bit surprised that your cluster is stuck here. I'm curious about what other recoveries are taking place preventing this one. Can you share the output of `GET _cat/recovery`?

---

<div class="post-metadata">

**Author:** ![amitavmohanty01](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/amitavmohanty01/32/58017_2.png) [@amitavmohanty01](https://discuss.elastic.co/u/amitavmohanty01)\
**Post date:** [December 31, 2018, 8:08am UTC](https://discuss.elastic.co/t/primary-shard-not-available/161687/5 "2018-12-31T08:08:39Z")

</div>

[https://dpaste.de/MPT6](https://dpaste.de/MPT6) is the output.

---

<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:** [December 31, 2018, 8:34am UTC](https://discuss.elastic.co/t/primary-shard-not-available/161687/6 "2018-12-31T08:34:48Z")

</div>

I do not see any incomplete recoveries in that output.

However, you seem to have far too many shards for the amount of data you are dealing with. You have multiple daily indices, each with 15 shards, with many shards are smaller than 1MB in size and no shards larger than 400MB. This will certainly have an impact on your cluster performance. [This article](https://www.elastic.co/blog/how-many-shards-should-i-have-in-my-elasticsearch-cluster) gives advice on sharding, but the main point is you should aim for shards to be around 40GB in size. I think you could reasonably reduce the `number_of_shards` parameter to `1` on all these indices, and extend some of the daily indices to be weekly or monthly instead.

---

<div class="post-metadata">

**Author:** ![amitavmohanty01](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/amitavmohanty01/32/58017_2.png) [@amitavmohanty01](https://discuss.elastic.co/u/amitavmohanty01)\
**Post date:** [December 31, 2018, 10:04am UTC](https://discuss.elastic.co/t/primary-shard-not-available/161687/7 "2018-12-31T10:04:56Z")

</div>

I am working on your advice about the shards. However, my primary question is that if there are no incomplete recoveries why the exception about primary shard not being available. I got a repro of the problem today so I posted the details.

---

<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:** [December 31, 2018, 10:19am UTC](https://discuss.elastic.co/t/primary-shard-not-available/161687/8 "2018-12-31T10:19:25Z")

</div>

Ok, a bit more context would help! It wasn't clear that there was any issue, and remains unclear that it's still the same issue.

Which shard is reported as unavailable? What does the allocation explain API say about it?

---

<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:** [January 28, 2019, 10:19am UTC](https://discuss.elastic.co/t/primary-shard-not-available/161687/9 "2019-01-28T10:19:35Z")

</div>

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