# IllegalStateException: Alias has more than one write index

**URL:** <https://discuss.elastic.co/t/illegalstateexception-alias-has-more-than-one-write-index/210771>\
**Category:** Elasticsearch\
**Tags:** ilm-index-lifecycle-management\
**Created:** [December 5, 2019, 7:17pm UTC](https://discuss.elastic.co/t/illegalstateexception-alias-has-more-than-one-write-index/210771 "2019-12-05T19:17:20Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![tami](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tami/32/45312_2.png) [@tami](https://discuss.elastic.co/u/tami)\
**Post date:** [December 5, 2019, 7:17pm UTC](https://discuss.elastic.co/t/illegalstateexception-alias-has-more-than-one-write-index/210771/1 "2019-12-05T19:17:21Z")

</div>

We are running version 6.8.3 with a 3.2.2 (master.client.data) setup. Our cluster is currently in the reds state:

```auto
curl -X GET '$HOST/_cat/health'
1575572989 19:09:49 es-cluster-dogfood red 6 1 1050 1050 0 0 1116 0 - 48.5%

```

We are seeing some weird errors related to one of our index alias's from an ILM Policy. One of our data nodes is crash looping with the other node running fine. Because of this, the second data node is unable to join the cluster and none of the secondary index shards are able to assigned. This is the error from the logs on that data node:

```auto
org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:163) ~[elasticsearch-6.8.3.jar:6.8.3] at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:150) ~[elasticsearch-6.8.3.jar:6.8.3] at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86) ~[elasticsearch-6.8.3.jar:6.8.3] at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124) ~[elasticsearch-cli-6.8.3.jar:6.8.3] at org.elasticsearch.cli.Command.main(Command.java:90) ~[elasticsearch-cli-6.8.3.jar:6.8.3] at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:116) ~[elasticsearch-6.8.3.jar:6.8.3] at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:93) ~[elasticsearch-6.8.3.jar:6.8.3] Caused by: java.lang.IllegalStateException: alias [counter-alias] has more than one write index [counter-000014,counter-000013] at org.elasticsearch.cluster.metadata.AliasOrIndex$Alias.computeAndValidateWriteIndex(AliasOrIndex.java:173) ~[elasticsearch-6.8.3.jar:6.8.3] at org.elasticsearch.cluster.metadata.MetaData$Builder.lambda$buildAliasAndIndexLookup$1(MetaData.java:1158) ~[elasticsearch-6.8.3.jar:6.8.3] at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183) ~[?:?] at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:177) ~[?:?] at java.util.TreeMap$ValueSpliterator.forEachRemaining(TreeMap.java:2890) ~[?:?] at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484) ~[?:?] at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474) ~[?:?] at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150) ~[?:?] at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173) ~[?:?] at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[?:?] at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:497) ~[?:?] at org.elasticsearch.cluster.metadata.MetaData$Builder.buildAliasAndIndexLookup(MetaData.java:1158) ~[elasticsearch-6.8.3.jar:6.8.3] at org.elasticsearch.cluster.metadata.MetaData$Builder.build(MetaData.java:1122) ~[elasticsearch-6.8.3.jar:6.8.3] at org.elasticsearch.gateway.MetaStateService.loadFullState(MetaStateService.java:73) ~[elasticsearch-6.8.3.jar:6.8.3] at org.elasticsearch.gateway.GatewayMetaState.<init>(GatewayMetaState.java:88) ~[elasticsearch-6.8.3.jar:6.8.3] at org.elasticsearch.node.Node.<init>(Node.java:499) ~[elasticsearch-6.8.3.jar:6.8.3] at org.elasticsearch.node.Node.<init>(Node.java:266) ~[elasticsearch-6.8.3.jar:6.8.3] at org.elasticsearch.bootstrap.Bootstrap$5.<init>(Bootstrap.java:212) ~[elasticsearch-6.8.3.jar:6.8.3] at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:212) ~[elasticsearch-6.8.3.jar:6.8.3] at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:333) ~[elasticsearch-6.8.3.jar:6.8.3] at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:159) ~[elasticsearch-6.8.3.jar:6.8.3] ... 6 more

```

The important part of this error is:  
`alias [counter-alias] has more than one write index [counter-000014,counter-000013]`

When i look at that alias though, it shows that only one of those indices are write enabled:

```auto
curl -X GET '$HOST/_alias/counter-alias?pretty'
{
  ...
  "counter-000013" : {
    "aliases" : {
      "counter-alias" : {
        "is_write_index" : false
      }
    }
  },
  ...
  "counter-000014" : {
    "aliases" : {
      "counter-alias" : {
        "is_write_index" : true
      }
    },
   ...
}

```

It seems to me like the state of the alias on the 2 data nodes might be inconsistent? And somehow the second data node has two indices write enabled?

Thanks in advance for the help.

---

<div class="post-metadata">

**Author:** ![tami](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tami/32/45312_2.png) [@tami](https://discuss.elastic.co/u/tami)\
**Post date:** [December 9, 2019, 4:34am UTC](https://discuss.elastic.co/t/illegalstateexception-alias-has-more-than-one-write-index/210771/2 "2019-12-09T04:34:33Z")

</div>

ping?

---

<div class="post-metadata">

**Author:** ![tami](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tami/32/45312_2.png) [@tami](https://discuss.elastic.co/u/tami)\
**Post date:** [December 11, 2019, 9:17pm UTC](https://discuss.elastic.co/t/illegalstateexception-alias-has-more-than-one-write-index/210771/3 "2019-12-11T21:17:07Z")

</div>

One more ping?

We'd like to try to root cause this, but if we get no reply we can just nuke the bad data node.

---

<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 8, 2020, 9:17pm UTC](https://discuss.elastic.co/t/illegalstateexception-alias-has-more-than-one-write-index/210771/4 "2020-01-08T21:17:07Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Stef\_Nestor](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stef_nestor/32/85483_2.png) [@Stef\_Nestor](https://discuss.elastic.co/u/Stef_Nestor)\
**Post date:** [August 3, 2021, 11:05pm UTC](https://discuss.elastic.co/t/illegalstateexception-alias-has-more-than-one-write-index/210771/5 "2021-08-03T23:05:58Z")

</div>

(Apologies for the original lask of response.)

For future note when searched, this is now answered in the blog [Troubleshooting ILM blog](https://www.elastic.co/blog/troubleshooting-elasticsearch-ilm-common-issues-and-fixes) & direct summarized answer is:

> When you run [Get Aliases](https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-alias.html), you’ll notice that two indices are marked as `is_write_index:true` when only one should be per alias. You’ll want to toggle `is_write_index:false` on one of the indices via the [Aliases API](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-aliases.html).
