Elasticsearch: Unable to delete snapshot “index and alias names need to be unique”

Created on 12 May 2016  ·  5Comments  ·  Source: elastic/elasticsearch

I already searched for a similar issue and posted about this in here and got no reply.
I looks like a bug so I'm opening this issue.

Elasticsearch version:
2.1.2

JVM version:
java version "1.8.0_72"
Java(TM) SE Runtime Environment (build 1.8.0_72-b15)
Java HotSpot(TM) 64-Bit Server VM (build 25.72-b15, mixed mode)

OS version:
Red Hat Enterprise Linux Server release 6.7 (Santiago)

Description of the problem including expected versus actual behavior:
I am unable to delete snapshots created in a previous version of elasticsearch containing indices and aliases with the same name.
I am currently using 2.1.2 and I have created the snapshots back in 1.7.2.

When I try to delete a snapshot using:

curl -s -XDELETE localhost:9200/_snapshot/repoX/snapY?pretty

I get the following error message:

{
  "error" : {
  "root_cause" : [ {
  "type" : "remote_transport_exception",
  "reason" : "[cluster:admin/snapshot/delete]"
  } ],
  "type" : "illegal_state_exception",
  "reason" : "index and alias names need to be unique, but alias [indexZ] and index [indexZ] have the same name"
  },
  "status" : 500
}

This seems to be due to the restriction that I think was introduced in 2.0.0 that index and alias names must be unique in a cluster.

I would expect deleting a snapshot to always work, despite it containing invalid indices and aliases names, since I am disposing of it.

This is preventing me from releasing valuable disk space in a production system.

Steps to reproduce:

  1. Create an index and alias with the same name in a version of elasticsearch where this is allowed (e.g. 1.7.2).
  2. Create a snapshot including that index and that alias.
  3. Upgrade to a version of elasticsearch where index and alias names must be unique (e.g. 2.1.2), first deleting either the index or the alias to ensure uniqueness
  4. Try to delete the snapshot created in the previous elasticsearch version.

Provide logs (if relevant):

[2016-05-12 18:25:52,981][INFO ][rest.suppressed          ] /_snapshot/repoX/snapY Params: {pretty=, repository=repoX, snapshot=snapY}
RemoteTransportException[[****][****:9300][cluster:admin/snapshot/delete]]; nested: IllegalStateException[index and alias names need to be unique, but alias [indexZ] and index [indexZ] have the same name];
Caused by: java.lang.IllegalStateException: index and alias names need to be unique, but alias [indexZ] and index [indexZ] have the same name
        at org.elasticsearch.cluster.metadata.MetaData$Builder.build(MetaData.java:1037)
        at org.elasticsearch.repositories.blobstore.BlobStoreRepository.readSnapshotMetaData(BlobStoreRepository.java:490)
        at org.elasticsearch.repositories.blobstore.BlobStoreRepository.deleteSnapshot(BlobStoreRepository.java:310)
        at org.elasticsearch.snapshots.SnapshotsService$8.run(SnapshotsService.java:997)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
:DistributeSnapshoRestore >bug discuss

Most helpful comment

I'm getting a similar error when I try to start elasticsearch:
java.lang.IllegalStateException: index and alias names need to be unique, but alias [people] and index [people] have the same name
I tried curl -XDELETE 'http://localhost:9200/_all but I'm still getting the same error.

All 5 comments

Hi @jdlourenco

Yes, it's a problem. Fortunately, the answer is easy: set up a single node of 1.7.5, add the repository in question and delete the snapshot.

I understand your hack but why did you close the issue?
Shouldn't it be fixed?

I don't think having to go back to a previous version of elasticsearch a very neat solution.

Perhaps deleting snapshots should work even if they contain invalid data since it won't be restored.

@jdlourenco the fact that an index and an alias could have the same name was a bug, which has been fixed. unfortunately it resulted in you getting into a tricky position. i don't think there is anything left to fix here, especially as there is a workaround (even though it may be hacky) for the situation you found yourself in.

I'm getting a similar error when I try to start elasticsearch:
java.lang.IllegalStateException: index and alias names need to be unique, but alias [people] and index [people] have the same name
I tried curl -XDELETE 'http://localhost:9200/_all but I'm still getting the same error.

@baileyspace Try going into your elasticsearch folder and deleting the stored indices. I had two that were in conflict, and deleting them solved the issue.

~/elasticsearch-2.3.4/data/elasticsearch/nodes

then delete each folder in the nodes directory.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

clintongormley picture clintongormley  ·  3Comments

DhairyashilBhosale picture DhairyashilBhosale  ·  3Comments

rjernst picture rjernst  ·  3Comments

matthughes picture matthughes  ·  3Comments

rpalsaxena picture rpalsaxena  ·  3Comments