Deleting index – How to solve this Elasticsearch error

Opster Team

Aug-23, Version: 6.8-8.9

Briefly, this error occurs when you attempt to delete an index that doesn’t exist, is already deleted, or is currently in use. It could also be due to insufficient permissions. To resolve this, ensure the index exists and is not in use before deleting. If it’s a permissions issue, adjust the user’s permissions to allow index deletion. Alternatively, if the index is in use, consider stopping the processes using it before deletion.

We recommend you run Elasticsearch Error Check-Up that will review your configuration and resolve issues that cause many errors.

This guide will explain what causes the log “deleting index” to appear and how to resolve this.

Background

To learn about indices in Elasticsearch, read this guide: Elasticsearch Index.

What does this message mean?

When you use the DELETE API, you’ll see the following logs:

[2022-02-12T13:15:46,541][INFO ][o.e.c.m.MetadataDeleteIndexService] [opster] [my_index/gnQA70A1TVWFns7Yp2728Q] deleting index

This is an INFO message informing you that the index `my_index` is being removed from the node.

It’s very important to know that If you don’t have a snapshot or backup set up, you won’t be able to recover the index once it’s been removed.

How to reproduce this log

Make sure your Elasticsearch instance is running before proceeding with the following steps.

Create index:

Using the PUT API, create an index (let’s call it `my_index`):

PUT /my_index

Delete index:

The next step is to use the DELETE API to delete the index:

DELETE /my_index

Log Context

Log “{} deleting index” classname is MetadataDeleteIndexService.java.
We extracted the following from Elasticsearch source code for those seeking an in-depth context :

        final IndexGraveyard.Builder graveyardBuilder = IndexGraveyard.builder(metadataBuilder.indexGraveyard());
        final int previousGraveyardSize = graveyardBuilder.tombstones().size();
        for (final Index index : indices) {
            String indexName = index.getName();
            logger.info("{} deleting index"; index);
            routingTableBuilder.remove(indexName);
            clusterBlocksBuilder.removeIndexBlocks(indexName);
            metadataBuilder.remove(indexName);
            if (backingIndices.containsKey(index)) {
                DataStream parent = metadataBuilder.dataStream(backingIndices.get(index).getName());

 

How helpful was this guide?

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?