# Indices replicas are set to 0 during night? \[7.11.2\]

**URL:** <https://discuss.elastic.co/t/indices-replicas-are-set-to-0-during-night-7-11-2/283627>\
**Category:** Elasticsearch\
**Created:** [September 8, 2021, 8:29am UTC](https://discuss.elastic.co/t/indices-replicas-are-set-to-0-during-night-7-11-2/283627 "2021-09-08T08:29:56Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mbooh](https://avatars.discourse-cdn.com/v4/letter/m/e495f1/32.png) [@mbooh](https://discuss.elastic.co/u/mbooh)\
**Post date:** [September 8, 2021, 8:29am UTC](https://discuss.elastic.co/t/indices-replicas-are-set-to-0-during-night-7-11-2/283627/1 "2021-09-08T08:29:56Z")

</div>

Hi!

I have a strange behavior. During night one of my indices lost a replica setting? Yesterday everything worked fine, they both had 1 replica but this morning it is 0 on one of them meaning when I close one node down I get the "all shards failed" error. How can that be?  
I set the replicas with a POST command, can it be specified in the .yaml instead?

```auto
health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
green open klaranatetwebutv2_2 QZvcjC9JQhehCiTT7BHxEQ 1 1 48519 17690 526.3mb 263.1mb
green open klaranatetwebutv2_1 jKF9YttySPuQ6H8EkiDzpw 1 0 48519 664 163.7mb 163.7mb

```

And why is there \_1 and \_2? That i don't really understand as well.

```auto
[2021-09-08T10:19:28,603][WARN][r.suppressed] [STHLM-KLARA-04] path: /klaranatetwebutv2_1/_search, params: {typed_keys=true, index=klaranatetwebutv2_1}
org.elasticsearch.action.search.SearchPhaseExecutionException: all shards failed
	at org.elasticsearch.action.search.AbstractSearchAsyncAction.onPhaseFailure(AbstractSearchAsyncAction.java:601) [elasticsearch-7.11.2.jar:7.11.2]
	at org.elasticsearch.action.search.AbstractSearchAsyncAction.executeNextPhase(AbstractSearchAsyncAction.java:332) [elasticsearch-7.11.2.jar:7.11.2]
	at org.elasticsearch.action.search.AbstractSearchAsyncAction.onPhaseDone(AbstractSearchAsyncAction.java:636) [elasticsearch-7.11.2.jar:7.11.2]
	at org.elasticsearch.action.search.AbstractSearchAsyncAction.onShardFailure(AbstractSearchAsyncAction.java:415) [elasticsearch-7.11.2.jar:7.11.2]
	at org.elasticsearch.action.search.AbstractSearchAsyncAction.lambda$performPhaseOnShard$0(AbstractSearchAsyncAction.java:240) [elasticsearch-7.11.2.jar:7.11.2]
	at org.elasticsearch.action.search.AbstractSearchAsyncAction$2.doRun(AbstractSearchAsyncAction.java:308) [elasticsearch-7.11.2.jar:7.11.2]
	at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:26) [elasticsearch-7.11.2.jar:7.11.2]
	at org.elasticsearch.common.util.concurrent.TimedRunnable.doRun(TimedRunnable.java:33) [elasticsearch-7.11.2.jar:7.11.2]
	at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:732) [elasticsearch-7.11.2.jar:7.11.2]
	at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:26) [elasticsearch-7.11.2.jar:7.11.2]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130) [?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630) [?:?]
	at java.lang.Thread.run(Thread.java:832) [?:?]
Caused by: org.elasticsearch.action.NoShardAvailableActionException
	at org.elasticsearch.action.search.AbstractSearchAsyncAction.onShardFailure(AbstractSearchAsyncAction.java:448) ~[elasticsearch-7.11.2.jar:7.11.2]
	at org.elasticsearch.action.search.AbstractSearchAsyncAction.onShardFailure(AbstractSearchAsyncAction.java:397) [elasticsearch-7.11.2.jar:7.11.2]

```

Thanks for your help!

/Kristoffer

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [September 8, 2021, 9:46am UTC](https://discuss.elastic.co/t/indices-replicas-are-set-to-0-during-night-7-11-2/283627/2 "2021-09-08T09:46:39Z")

</div>

Do the logs on the master mention anything about the index during this time?

---

<div class="post-metadata">

**Author:** ![mbooh](https://avatars.discourse-cdn.com/v4/letter/m/e495f1/32.png) [@mbooh](https://discuss.elastic.co/u/mbooh)\
**Post date:** [September 8, 2021, 11:39am UTC](https://discuss.elastic.co/t/indices-replicas-are-set-to-0-during-night-7-11-2/283627/3 "2021-09-08T11:39:34Z")

</div>

I found this in the current master node log from tonight:

```auto
[2021-09-08T02:24:00,343][INFO][o.e.x.m.MlDailyMaintenanceService] [STHLM-KLARA-04] triggering scheduled [ML] maintenance tasks
[2021-09-08T02:24:00,358][INFO][o.e.x.m.a.TransportDeleteExpiredDataAction] [STHLM-KLARA-04] Deleting expired data
[2021-09-08T02:24:00,405][INFO][o.e.x.m.j.r.UnusedStatsRemover] [STHLM-KLARA-04] Successfully deleted [0] unused stats documents
[2021-09-08T02:24:00,421][INFO][o.e.x.m.a.TransportDeleteExpiredDataAction] [STHLM-KLARA-04] Completed deletion of expired ML data
[2021-09-08T02:24:00,421][INFO][o.e.x.m.MlDailyMaintenanceService] [STHLM-KLARA-04] Successfully completed [ML] maintenance task: triggerDeleteExpiredDataTask
[2021-09-08T03:30:00,392][INFO][o.e.x.s.SnapshotRetentionTask] [STHLM-KLARA-04] starting SLM retention snapshot cleanup task
[2021-09-08T03:30:00,392][INFO][o.e.x.s.SnapshotRetentionTask] [STHLM-KLARA-04] there are no repositories to fetch, SLM retention snapshot cleanup task complete
[2021-09-08T07:30:00,557][INFO][o.e.c.m.MetadataDeleteIndexService] [STHLM-KLARA-04] [klaranatetwebutv2_1/ZPmtXs0rToKdwe_Pz5639Q] deleting index
[2021-09-08T07:30:01,255][INFO][o.e.c.m.MetadataCreateIndexService] [STHLM-KLARA-04] [klaranatetwebutv2_1] creating index, cause [api], templates [], shards [1]/[0]
[2021-09-08T07:30:01,446][INFO][o.e.c.r.a.AllocationService] [STHLM-KLARA-04] Cluster health status changed from [YELLOW] to [GREEN] (reason: [shards started [[klaranatetwebutv2_1][0]]]).
[2021-09-08T07:30:01,683][INFO][o.e.c.m.MetadataMappingService] [STHLM-KLARA-04] [klaranatetwebutv2_1/jKF9YttySPuQ6H8EkiDzpw] create_mapping [_doc]

```

It looks like index are deleted and created, could that be the thing and that they are created without replicas?

/Kristoffer

---

<div class="post-metadata">

**Author:** ![mbooh](https://avatars.discourse-cdn.com/v4/letter/m/e495f1/32.png) [@mbooh](https://discuss.elastic.co/u/mbooh)\
**Post date:** [September 8, 2021, 4:34pm UTC](https://discuss.elastic.co/t/indices-replicas-are-set-to-0-during-night-7-11-2/283627/4 "2021-09-08T16:34:49Z")

</div>

Hi! So I found it. It looks like the index is deleted and created by code using [Elasticsearch.Net](http://Elasticsearch.Net) and when that is done this code is run:

```auto
var createIndexResponse = Indices.Create(indexName, createIndex => createIndex
                    .Settings(settings => settings
                        .NumberOfShards(1)
                        .NumberOfReplicas(0)
                        .Analysis(analysis => analysisSettings))
                    .Timeout(TimeSpan.FromSeconds(60)));

```

No wonder the index was created without replica!

/Kristoffer

---

<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:** [October 6, 2021, 4:35pm UTC](https://discuss.elastic.co/t/indices-replicas-are-set-to-0-during-night-7-11-2/283627/5 "2021-10-06T16:35:34Z")

</div>

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