# Index lifecycle management runs into IndexNotFoundException

**URL:** <https://discuss.elastic.co/t/index-lifecycle-management-runs-into-indexnotfoundexception/169625>\
**Category:** Elasticsearch\
**Created:** [February 22, 2019, 7:16pm UTC](https://discuss.elastic.co/t/index-lifecycle-management-runs-into-indexnotfoundexception/169625 "2019-02-22T19:16:49Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![wei1](https://avatars.discourse-cdn.com/v4/letter/w/fbc32d/32.png) [@wei1](https://discuss.elastic.co/u/wei1)\
**Post date:** [February 22, 2019, 7:16pm UTC](https://discuss.elastic.co/t/index-lifecycle-management-runs-into-indexnotfoundexception/169625/1 "2019-02-22T19:16:49Z")

</div>

Hi, I'm starting to use index lifecycle management policy to delete index that's been created for xx time. Here's the policy:

```
{ "policy": {
    "phases": {
        "hot": {
            "actions": {}},
        "delete": {
            "min_age": xx,
            "actions": {
                "delete": {}}}}}

```

The deletion min\_age is a variable, and the policy is in an index template.  
In test, I set the delete min\_age to be 50ms, create an index template that has the policy, create an index that follows the template, and then wait for 50ms and check in a loop whether the index is deleted.  
But I sometimes ran into

> org.elasticsearch.index.IndexNotFoundException: no such index

other times the test passes.  
Here's the more detailed log:

```
[2019-02-22T15:39:56,990][INFO][o.e.c.m.MetaDataIndexTemplateService] [ejsJGon] adding template [template_test-1550849985826781595] for index patterns [test-1550849985826781595-*]
[2019-02-22T15:39:57,656][INFO][o.e.c.m.MetaDataCreateIndexService] [ejsJGon] [test-1550849985826781595-2019-02-11] creating index, cause [api], templates [template_test-1550849985826781595], shards [5]/[2], mappings [_doc]
[2019-02-22T15:40:05,073][INFO][o.e.c.m.MetaDataDeleteIndexService] [ejsJGon] [test-1550849985826781595-2019-02-11/yD0Ns76GR3WddMX_sjRoNQ] deleting index
[2019-02-22T15:40:05,207][ERROR][o.e.x.i.IndexLifecycleRunner] [ejsJGon] policy [test-1550849985826781595_policy] for index [test-1550849985826781595-2019-02-11] failed on step [{"phase":"delete","action":"delete","name":"delete"}]. Moving to ERROR step
org.elasticsearch.index.IndexNotFoundException: no such index
	at org.elasticsearch.cluster.metadata.MetaData.getIndexSafe(MetaData.java:614) ~[elasticsearch-6.6.0.jar:6.6.0]
	at org.elasticsearch.cluster.metadata.MetaDataDeleteIndexService.lambda$deleteIndices$0(MetaDataDeleteIndexService.java:93) ~[elasticsearch-6.6.0.jar:6.6.0]
	at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195) ~[?:?]
	at java.util.HashMap$KeySpliterator.forEachRemaining(HashMap.java:1603) ~[?:?]
	at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484) ~[?:?]
	at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474) ~[?:?]
	at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913) ~[?:?]
	at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[?:?]
	at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:578) ~[?:?]
	at org.elasticsearch.cluster.metadata.MetaDataDeleteIndexService.deleteIndices(MetaDataDeleteIndexService.java:93) ~[elasticsearch-6.6.0.jar:6.6.0]
	at org.elasticsearch.cluster.metadata.MetaDataDeleteIndexService$1.execute(MetaDataDeleteIndexService.java:83) ~[elasticsearch-6.6.0.jar:6.6.0]
	at org.elasticsearch.cluster.ClusterStateUpdateTask.execute(ClusterStateUpdateTask.java:47) ~[elasticsearch-6.6.0.jar:6.6.0]
	at org.elasticsearch.cluster.service.MasterService.executeTasks(MasterService.java:643) ~[elasticsearch-6.6.0.jar:6.6.0]
	at org.elasticsearch.cluster.service.MasterService.calculateTaskOutputs(MasterService.java:272) ~[elasticsearch-6.6.0.jar:6.6.0]
	at org.elasticsearch.cluster.service.MasterService.runTasks(MasterService.java:202) [elasticsearch-6.6.0.jar:6.6.0]
	at org.elasticsearch.cluster.service.MasterService$Batcher.run(MasterService.java:137) [elasticsearch-6.6.0.jar:6.6.0]
	at org.elasticsearch.cluster.service.TaskBatcher.runIfNotProcessed(TaskBatcher.java:150) [elasticsearch-6.6.0.jar:6.6.0]
	at org.elasticsearch.cluster.service.TaskBatcher$BatchedTask.run(TaskBatcher.java:188) [elasticsearch-6.6.0.jar:6.6.0]
	at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingRunnable.run(ThreadContext.java:660) [elasticsearch-6.6.0.jar:6.6.0]
	at org.elasticsearch.common.util.concurrent.PrioritizedEsThreadPoolExecutor$TieBreakingPrioritizedRunnable.runAndClean(PrioritizedEsThreadPoolExecutor.java:244) [elasticsearch-6.6.0.jar:6.6.0]
	at org.elasticsearch.common.util.concurrent.PrioritizedEsThreadPoolExecutor$TieBreakingPrioritizedRunnable.run(PrioritizedEsThreadPoolExecutor.java:207) [elasticsearch-6.6.0.jar:6.6.0]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
	at java.lang.Thread.run(Thread.java:834) [?:?]

```

So in the log, the IndexLifecycleRunner can specify the correct index name, but it cannot find the index.  
Is that because 50ms is too small? Can I get some help regarding this? Thanks!

---

<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:** [February 24, 2019, 7:53pm UTC](https://discuss.elastic.co/t/index-lifecycle-management-runs-into-indexnotfoundexception/169625/2 "2019-02-24T19:53:02Z")

</div>

I do not see the point in setting `min_age` to 50ms. What is the usecase? What are you trying to test or achieve?

---

<div class="post-metadata">

**Author:** ![wei1](https://avatars.discourse-cdn.com/v4/letter/w/fbc32d/32.png) [@wei1](https://discuss.elastic.co/u/wei1)\
**Post date:** [February 25, 2019, 7:33pm UTC](https://discuss.elastic.co/t/index-lifecycle-management-runs-into-indexnotfoundexception/169625/3 "2019-02-25T19:33:54Z")

</div>

Thanks for replying. I'm trying to test if my ilm policy definition is correct and how it's integrated into index template is correct in my code. By setting the `min_age` to a small value, I can test whether it's working in a go unit test. The use case is eventually to use ilm to delete index older than 28 days. Right now we're using curator to delete old indices, and would like to replace it with the ilm.

---

<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:** [February 25, 2019, 7:59pm UTC](https://discuss.elastic.co/t/index-lifecycle-management-runs-into-indexnotfoundexception/169625/4 "2019-02-25T19:59:58Z")

</div>

I do not that think that is going to work as I believe conditions are checked periodically at an interval far greater than the timeout you have specified. Indices are expected to be reasonably long lived, so it does not make any sense checking condition extremely frequently if this adds load to the cluster.

---

<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:** [March 25, 2019, 8:00pm UTC](https://discuss.elastic.co/t/index-lifecycle-management-runs-into-indexnotfoundexception/169625/5 "2019-03-25T20:00:07Z")

</div>

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