diff --git a/server/src/main/java/org/elasticsearch/index/shard/IndexShard.java b/server/src/main/java/org/elasticsearch/index/shard/IndexShard.java index 9ba027091cf3a..92abbf0710e33 100644 --- a/server/src/main/java/org/elasticsearch/index/shard/IndexShard.java +++ b/server/src/main/java/org/elasticsearch/index/shard/IndexShard.java @@ -609,7 +609,7 @@ public void onFailure(Exception e) { indexEventListener.shardRoutingChanged(this, currentRouting, newRouting); } - if (indexSettings.isSoftDeleteEnabled() && useRetentionLeasesInPeerRecovery == false) { + if (indexSettings.isSoftDeleteEnabled() && useRetentionLeasesInPeerRecovery == false && state() == IndexShardState.STARTED) { final RetentionLeases retentionLeases = replicationTracker.getRetentionLeases(); final Set shardRoutings = new HashSet<>(routingTable.getShards()); shardRoutings.addAll(routingTable.assignedShards()); // include relocation targets