# Not enough active copies to meet write consistency of \[ALL\]

**URL:** <https://discuss.elastic.co/t/not-enough-active-copies-to-meet-write-consistency-of-all/44663>\
**Category:** Elasticsearch\
**Created:** [March 17, 2016, 7:22am UTC](https://discuss.elastic.co/t/not-enough-active-copies-to-meet-write-consistency-of-all/44663 "2016-03-17T07:22:53Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![sumanbn](https://avatars.discourse-cdn.com/v4/letter/s/51bf81/32.png) [@sumanbn](https://discuss.elastic.co/u/sumanbn)\
**Post date:** [March 17, 2016, 7:22am UTC](https://discuss.elastic.co/t/not-enough-active-copies-to-meet-write-consistency-of-all/44663/1 "2016-03-17T07:22:53Z")

</div>

I have set Conssistency level to "writeConsistencyLevel.ALL"  
But when trying to write , i get belo exception:

! org.elasticsearch.action.UnavailableShardsException: [app-names][0] Not enough active copies to meet write consistency of [ALL] (have 1, needed 2). Timeout: [1m], request: index  
! at org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$PrimaryPhase.retryBecauseUnavailable(TransportShardReplicationOperationAction.java:655) ~  
! at org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$PrimaryPhase.performOnPrimary(TransportShardReplicationOperationAction.java:567) ~  
! at org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$PrimaryPhase$1.doRun(TransportShardReplicationOperationAction.java:440)  
! at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:36) ~  
! at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) ~[na:1.8.0\_51]  
! at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) ~[na:1.8.0\_51]  
! at java.lang.Thread.run(Thread.java:745) [na:1.8.0\_51]

Let me know how this can be fixed.

Regards,  
Suman

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [March 17, 2016, 7:46am UTC](https://discuss.elastic.co/t/not-enough-active-copies-to-meet-write-consistency-of-all/44663/2 "2016-03-17T07:46:48Z")

</div>

It means that one of the shards was not available for writing, and the indexing operation therefore failed as per your setting. You either have to wait until all shards are available or relax the consistency level.

---

<div class="post-metadata">

**Author:** ![sumanbn](https://avatars.discourse-cdn.com/v4/letter/s/51bf81/32.png) [@sumanbn](https://discuss.elastic.co/u/sumanbn)\
**Post date:** [March 17, 2016, 7:54am UTC](https://discuss.elastic.co/t/not-enough-active-copies-to-meet-write-consistency-of-all/44663/3 "2016-03-17T07:54:52Z")

</div>

I am using the default elasticsearch.yml. All the values are default apart from the cluster name. And my ES is running locally. Can you suggest the changes/ mistakes.

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [March 17, 2016, 8:47am UTC](https://discuss.elastic.co/t/not-enough-active-copies-to-meet-write-consistency-of-all/44663/4 "2016-03-17T08:47:03Z")

</div>

> [@sumanbn](#):
>
> I have set Conssistency level to "writeConsistencyLevel.ALL"

As far as I know this is not the default value, and is what is causing Elasticsearch to reject the write.

If you are running on a single node cluster changing this setting makes no sense as Elasticsearch will never allocate a primary and replica shard to the same node. The replica will therefore remain unassigned until you add another node, and this setting will fail all writes until that happens. You can get around this by changing the number of replicas for the index to 0.

---

<div class="post-metadata">

**Author:** ![sumanbn](https://avatars.discourse-cdn.com/v4/letter/s/51bf81/32.png) [@sumanbn](https://discuss.elastic.co/u/sumanbn)\
**Post date:** [March 17, 2016, 11:41am UTC](https://discuss.elastic.co/t/not-enough-active-copies-to-meet-write-consistency-of-all/44663/5 "2016-03-17T11:41:07Z")

</div>

Setting the index.number\_of\_replicas to 0 doesn't help.

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [March 17, 2016, 12:14pm UTC](https://discuss.elastic.co/t/not-enough-active-copies-to-meet-write-consistency-of-all/44663/6 "2016-03-17T12:14:03Z")

</div>

How are you setting it? Are you setting it in elasticsearch.yml or updating the setting for each existing index?

---

<div class="post-metadata">

**Author:** ![sumanbn](https://avatars.discourse-cdn.com/v4/letter/s/51bf81/32.png) [@sumanbn](https://discuss.elastic.co/u/sumanbn)\
**Post date:** [March 17, 2016, 2:08pm UTC](https://discuss.elastic.co/t/not-enough-active-copies-to-meet-write-consistency-of-all/44663/7 "2016-03-17T14:08:18Z")

</div>

Setting it in elasticsearch.yml

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [March 17, 2016, 2:20pm UTC](https://discuss.elastic.co/t/not-enough-active-copies-to-meet-write-consistency-of-all/44663/8 "2016-03-17T14:20:38Z")

</div>

That setting is the default setting and only applied as new indices are created. You will need to [update the settings of the existing indices](https://www.elastic.co/guide/en/elasticsearch/reference/2.2/index-modules.html#dynamic-index-settings).

---

<div class="post-metadata">

**Author:** ![sumanbn](https://avatars.discourse-cdn.com/v4/letter/s/51bf81/32.png) [@sumanbn](https://discuss.elastic.co/u/sumanbn)\
**Post date:** [March 17, 2016, 2:47pm UTC](https://discuss.elastic.co/t/not-enough-active-copies-to-meet-write-consistency-of-all/44663/9 "2016-03-17T14:47:33Z")

</div>

I am actually dropping all indices. Then make the settings and bring up the elasticsearch.  
And then create the indices. So the changes should be effective. But still it doesn't work. Let me know if there is anything wrong.

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [March 17, 2016, 2:49pm UTC](https://discuss.elastic.co/t/not-enough-active-copies-to-meet-write-consistency-of-all/44663/10 "2016-03-17T14:49:50Z")

</div>

What does your configuration look like? When you have recreated indices, what does the output from `_cat/indices` look like?

---

<div class="post-metadata">

**Author:** ![sumanbn](https://avatars.discourse-cdn.com/v4/letter/s/51bf81/32.png) [@sumanbn](https://discuss.elastic.co/u/sumanbn)\
**Post date:** [March 17, 2016, 3:05pm UTC](https://discuss.elastic.co/t/not-enough-active-copies-to-meet-write-consistency-of-all/44663/11 "2016-03-17T15:05:42Z")

</div>

health status index pri rep docs.count docs.deleted store.size pri.store.size  
green open app-names 5 0 1 0 3kb 3kb

---

<div class="post-metadata">

**Author:** ![sumanbn](https://avatars.discourse-cdn.com/v4/letter/s/51bf81/32.png) [@sumanbn](https://discuss.elastic.co/u/sumanbn)\
**Post date:** [March 18, 2016, 6:48am UTC](https://discuss.elastic.co/t/not-enough-active-copies-to-meet-write-consistency-of-all/44663/12 "2016-03-18T06:48:45Z")

</div>

@Christian_Dahlqvist Any suggestions? Still facing the issue. Pls help.

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [March 18, 2016, 6:51am UTC](https://discuss.elastic.co/t/not-enough-active-copies-to-meet-write-consistency-of-all/44663/13 "2016-03-18T06:51:02Z")

</div>

Are you still seeing exactly the same error message when trying to index into the app-names index?

---

<div class="post-metadata">

**Author:** ![sumanbn](https://avatars.discourse-cdn.com/v4/letter/s/51bf81/32.png) [@sumanbn](https://discuss.elastic.co/u/sumanbn)\
**Post date:** [March 18, 2016, 6:51am UTC](https://discuss.elastic.co/t/not-enough-active-copies-to-meet-write-consistency-of-all/44663/14 "2016-03-18T06:51:50Z")

</div>

No. But it saves the index and refresh doesn't happen.

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [March 18, 2016, 7:16am UTC](https://discuss.elastic.co/t/not-enough-active-copies-to-meet-write-consistency-of-all/44663/15 "2016-03-18T07:16:27Z")

</div>

What is your refresh interval set to? Are you able to retrieve the indexed record through the [GET API](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-get.html)?

---

<div class="post-metadata">

**Author:** ![sumanbn](https://avatars.discourse-cdn.com/v4/letter/s/51bf81/32.png) [@sumanbn](https://discuss.elastic.co/u/sumanbn)\
**Post date:** [March 18, 2016, 8:17am UTC](https://discuss.elastic.co/t/not-enough-active-copies-to-meet-write-consistency-of-all/44663/16 "2016-03-18T08:17:12Z")

</div>

Yes I am able to get the indexed record though GET API. I don't want to do a explicit refresh by forcing an index refresh.

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [March 18, 2016, 8:35am UTC](https://discuss.elastic.co/t/not-enough-active-copies-to-meet-write-consistency-of-all/44663/17 "2016-03-18T08:35:51Z")

</div>

The default refresh interval is 1 second, so unless you have modified this I do not see why the data should not be made available for search.

---

<div class="post-metadata">

**Author:** ![avanish\_pandey](https://avatars.discourse-cdn.com/v4/letter/a/e95f7d/32.png) [@avanish\_pandey](https://discuss.elastic.co/u/avanish_pandey)\
**Post date:** [April 1, 2016, 7:28am UTC](https://discuss.elastic.co/t/not-enough-active-copies-to-meet-write-consistency-of-all/44663/18 "2016-04-01T07:28:50Z")

</div>

I am facing a similar issue in my test cases. I have set the replica's to 0 and number\_of\_shards to 1. But i get this error "Not enough active copies to meet write consistency of [ALL] (have 1, needed 2)." Please suggest what could be the issue. Version used is 1.7.1.

---

<div class="post-metadata">

**Author:** ![javanna](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/javanna/32/4698_2.png) [@javanna](https://discuss.elastic.co/u/javanna)\
**Post date:** [April 1, 2016, 10:32am UTC](https://discuss.elastic.co/t/not-enough-active-copies-to-meet-write-consistency-of-all/44663/19 "2016-04-01T10:32:41Z")

</div>

"have 1 needed 2" means that the document should go to two shards, but only one is available. That tells us that the index you are indexing into has 1 replica, not 0, so for some reason setting replicas to 0 didn't work. Also, the default consistency is QUORUM, not ALL. Using consistency ALL in a single node cluster with an index with default settings would definitely cause this, as default settings are 5 shards and 1 replica, and replicas can not be unassigned on a single node cluster.

Let me know if this helps

---

<div class="post-metadata">

**Author:** ![avanish\_pandey](https://avatars.discourse-cdn.com/v4/letter/a/e95f7d/32.png) [@avanish\_pandey](https://discuss.elastic.co/u/avanish_pandey)\
**Post date:** [April 1, 2016, 12:47pm UTC](https://discuss.elastic.co/t/not-enough-active-copies-to-meet-write-consistency-of-all/44663/20 "2016-04-01T12:47:02Z")

</div>

This is how i am starting my server.  
`
final Map<String, String> settingsMap = new HashMap<>();
settingsMap.put("index.number_of_shards", "1");
settingsMap.put("index.number_of_replicas", "0");
Settings settings = ImmutableSettings.settingsBuilder().put(settingsMap).build();`

```
    node = nodeBuilder()
            .local(true)
            .settings(settings)
            .node();

```

Then i put a template mapping to this server and just send data from the test case. Is there any other way to handle this?

[Next page](https://discuss.elastic.co/t/not-enough-active-copies-to-meet-write-consistency-of-all/44663.md?page=2)
