# \[BUG\] A replica shard in POST\_RECOVERY state, when promoted to primary, will be stuck

**URL:** https://discuss.elastic.co/t/bug-a-replica-shard-in-post-recovery-state-when-promoted-to-primary-will-be-stuck/382333
**Category:** Elasticsearch
**Created:** [September 30, 2025, 9:16pm UTC](https://discuss.elastic.co/t/bug-a-replica-shard-in-post-recovery-state-when-promoted-to-primary-will-be-stuck/382333 "2025-09-30T21:16:16Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Govind\_Balaji\_S](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/govind_balaji_s/32/143590_2.png) [@Govind\_Balaji\_S](https://discuss.elastic.co/u/Govind_Balaji_S)
#### Post date: [September 30, 2025, 9:16pm UTC](https://discuss.elastic.co/t/bug-a-replica-shard-in-post-recovery-state-when-promoted-to-primary-will-be-stuck/382333/1 "2025-09-30T21:16:17Z")

</div>

EDIT: I think I mixed up ShardRoutingState and IndexShardState.

I think this introduced a bug - [A replica can be promoted and started in one cluster state update by bleskes · Pull Request #32042 · elastic/elasticsearch · GitHub](https://github.com/elastic/elasticsearch/pull/32042)

This commit maybe misses that currentRouting.initializing() does not include the IndexShardState.POST\_RECOVERY. It was intended to fix this kind of a bug for more general cases like this but looks like this case might have been dropped in the refactor.

## Steps to reproduce

(Non-deterministic)

After a restart of a 4 node cluster, (the index of interest in it is a single shard index with replicationFactor = 2)  
We saw all replicas of that single shard stuck in "INITIALIZING", while the primary shard had "STARTED" state.

Indexing kept failing with

```auto
{"type":"retry_on_primary_exception","reason":"shard is not in primary mode","index":" ***","shard":"0","index_uuid":"***","caused_by":{"type":"shard_not_in_primary_mode_exception","reason":"CurrentState[STARTED] shard is not in primary mode","index":" ***","shard":"0","index_uuid":"***"}

```

It appeared like an indexShard's shardRouting.primary was set to true, but replicationTracker.primary was not. Tracing code, this looks like the bug?

Version - opensearch 2.19.1 (this code path is still in elasticsearch master too)

---

<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: [September 30, 2025, 9:16pm UTC](https://discuss.elastic.co/t/bug-a-replica-shard-in-post-recovery-state-when-promoted-to-primary-will-be-stuck/382333/2 "2025-09-30T21:16:17Z")

</div>

OpenSearch/OpenDistro are AWS run products and differ from the original Elasticsearch and Kibana products that Elastic builds and maintains. You may need to contact them directly for further assistance. See [What is OpenSearch and the OpenSearch Dashboard? | Elastic](https://www.elastic.co/elasticsearch/opensearch) for more details.

(This is an automated response from your friendly Elastic bot. Please report this post if you have any suggestions or concerns :elasticheart: )
