# ILM is failing to delete closed indices

**URL:** https://discuss.elastic.co/t/ilm-is-failing-to-delete-closed-indices/372755
**Category:** Elasticsearch
**Tags:** ilm-index-lifecycle-management
**Created:** [January 3, 2025, 3:42pm UTC](https://discuss.elastic.co/t/ilm-is-failing-to-delete-closed-indices/372755 "2025-01-03T15:42:40Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![GustavoSantos](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gustavosantos/32/116751_2.png) [@GustavoSantos](https://discuss.elastic.co/u/GustavoSantos)
#### Post date: [January 3, 2025, 3:42pm UTC](https://discuss.elastic.co/t/ilm-is-failing-to-delete-closed-indices/372755/1 "2025-01-03T15:42:40Z")

</div>

ILM is failing to delete a few closed indices. We are getting the following issue:

`policy [<policyName>] for index [<indexName>] on an error step due to a transient error, moving back to the failed step [wait-for-shard-history-leases] for execution. retry attempt [20077]`

Cluster is health:

```auto
{
    "cluster_name": "es",
    "status": "green",
    "timed_out": false,
    "number_of_nodes": 9,
    "number_of_data_nodes": 6,
    "active_primary_shards": 1339,
    "active_shards": 2678,
    "relocating_shards": 0,
    "initializing_shards": 0,
    "unassigned_shards": 0,
    "delayed_unassigned_shards": 0,
    "number_of_pending_tasks": 0,
    "number_of_in_flight_fetch": 0,
    "task_max_waiting_in_queue_millis": 0,
    "active_shards_percent_as_number": 100.0
}

```

ILM policy:

```auto
"<policyName>": {
        "version": 1,
        "modified_date": "2023-06-28T17:44:22.693Z",
        "policy": {
            "phases": {
                "delete": {
                    "min_age": "122d",
                    "actions": {
                        "delete": {
                            "delete_searchable_snapshot": true
                        }
                    }
                }
            }
        },
        "in_use_by": {
            "indices": [
                <indicesToBeDeleted>
            ],
            "data_streams": [],
            "composable_templates": []
        }
    }

```

I couldn't find any explanation of what "wait-for-shard-history-leases" means in practice. According to other topics in this forum, ES is able to delete closed indices.

Can someone help?

Thank you.

---

<div class="post-metadata">

### Author: ![Musab\_Dogan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/musab_dogan/32/70691_2.png) [@Musab\_Dogan](https://discuss.elastic.co/u/Musab_Dogan)
#### Post date: [January 5, 2025, 3:29pm UTC](https://discuss.elastic.co/t/ilm-is-failing-to-delete-closed-indices/372755/2 "2025-01-05T15:29:14Z")

</div>

Why the indices are closed?

---

<div class="post-metadata">

### Author: ![GustavoSantos](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gustavosantos/32/116751_2.png) [@GustavoSantos](https://discuss.elastic.co/u/GustavoSantos)
#### Post date: [January 6, 2025, 10:38am UTC](https://discuss.elastic.co/t/ilm-is-failing-to-delete-closed-indices/372755/3 "2025-01-06T10:38:32Z")

</div>

They are closed because of some internal policies of our application.  
Does it matter? According to our understanding of ILM, they should be deleted by the ILM policy anyway.

---

<div class="post-metadata">

### Author: ![Musab\_Dogan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/musab_dogan/32/70691_2.png) [@Musab\_Dogan](https://discuss.elastic.co/u/Musab_Dogan)
#### Post date: [January 6, 2025, 11:46am UTC](https://discuss.elastic.co/t/ilm-is-failing-to-delete-closed-indices/372755/4 "2025-01-06T11:46:07Z")

</div>

Yes it matters. Closed indices remove can cause issue. Here are some similar discussions:

1. [Elasticsearch ILM failed delete closed indices](https://discuss.elastic.co/t/elasticsearch-ilm-failed-delete-closed-indices/354163)
2. [Index Lifecycle Management - closing indices](https://discuss.elastic.co/t/index-lifecycle-management-closing-indices/316757)

If you send close index request via application, It'd be better to remove or open the index via application again.

But the main question is "why you need to close indices?" like @Aaron mentioned in [here](https://discuss.elastic.co/t/index-lifecycle-management-closing-indices/316757/2).

---

<div class="post-metadata">

### Author: ![iamwander](https://avatars.discourse-cdn.com/v4/letter/i/8dc957/32.png) [@iamwander](https://discuss.elastic.co/u/iamwander)
#### Post date: [January 6, 2025, 12:41pm UTC](https://discuss.elastic.co/t/ilm-is-failing-to-delete-closed-indices/372755/5 "2025-01-06T12:41:26Z")

</div>

OKay

---

<div class="post-metadata">

### Author: ![GustavoSantos](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gustavosantos/32/116751_2.png) [@GustavoSantos](https://discuss.elastic.co/u/GustavoSantos)
#### Post date: [January 6, 2025, 2:32pm UTC](https://discuss.elastic.co/t/ilm-is-failing-to-delete-closed-indices/372755/6 "2025-01-06T14:32:57Z")

</div>

These indices shouldn't be closed. This is a result of a not gracefully aborted operation. In a normal situation, we don't have closed indices.

However, given the possibility of the exceptional scenario above, we were expecting ILM to be able to delete and therefore clean up these closed indices, as referenced in [Elasticsearch ILM failed delete closed indices - #2 by rtwolfe94022](https://discuss.elastic.co/t/elasticsearch-ilm-failed-delete-closed-indices/354163/2) : "Yes, ILM can delete closed indices"

---

<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: [January 6, 2025, 2:35pm UTC](https://discuss.elastic.co/t/ilm-is-failing-to-delete-closed-indices/372755/7 "2025-01-06T14:35:48Z")

</div>

That answer was provided by an non-Elastic volunteer so I am not sure why you are assuming that is correct.

Which version of Elasticsearch are you using?

---

<div class="post-metadata">

### Author: ![GustavoSantos](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gustavosantos/32/116751_2.png) [@GustavoSantos](https://discuss.elastic.co/u/GustavoSantos)
#### Post date: [January 6, 2025, 2:38pm UTC](https://discuss.elastic.co/t/ilm-is-failing-to-delete-closed-indices/372755/8 "2025-01-06T14:38:42Z")

</div>

I opened this topic to double-check that assumption.

> Which version of Elasticsearch are you using?  
> 8.9.1

So, can I assume ILM cannot delete closed indices?

---

<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: [January 6, 2025, 2:44pm UTC](https://discuss.elastic.co/t/ilm-is-failing-to-delete-closed-indices/372755/9 "2025-01-06T14:44:46Z")

</div>

> [@GustavoSantos](#):
>
> So, can I assume ILM cannot delete closed indices?

I do not know. It is probably best to wait for someone from Elastic to weigh in on the topic as it is not covered in the docs.
