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 d6b99afb9f66c..3679321b96539 100644 --- a/server/src/main/java/org/elasticsearch/index/shard/IndexShard.java +++ b/server/src/main/java/org/elasticsearch/index/shard/IndexShard.java @@ -606,7 +606,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