Skip to content

Commit 2ce9cd3

Browse files
Remove unnecessary shuffle in unassigned shards allocation. (#65172)
Shuffling to avoid poisonous shards no longer has any effect, since we always sort unassigned shards before iterating them for allocation.
1 parent 30ed6b0 commit 2ce9cd3

File tree

2 files changed

+0
-14
lines changed

2 files changed

+0
-14
lines changed

server/src/main/java/org/elasticsearch/cluster/routing/RoutingNodes.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import org.elasticsearch.cluster.routing.UnassignedInfo.AllocationStatus;
1919
import org.elasticsearch.cluster.routing.allocation.ExistingShardsAllocator;
2020
import org.elasticsearch.cluster.service.MasterService;
21-
import org.elasticsearch.common.Randomness;
2221
import org.elasticsearch.core.Nullable;
2322
import org.elasticsearch.core.Tuple;
2423
import org.elasticsearch.index.Index;
@@ -1068,11 +1067,6 @@ public boolean isIgnoredEmpty() {
10681067
return ignored.isEmpty();
10691068
}
10701069

1071-
public void shuffle() {
1072-
nodes.ensureMutable();
1073-
Randomness.shuffle(unassigned);
1074-
}
1075-
10761070
/**
10771071
* Drains all unassigned shards and returns it.
10781072
* This method will not drain ignored shards.

server/src/main/java/org/elasticsearch/cluster/routing/allocation/AllocationService.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,6 @@ public ClusterState applyStartedShards(ClusterState clusterState, List<ShardRout
117117
return clusterState;
118118
}
119119
RoutingNodes routingNodes = getMutableRoutingNodes(clusterState);
120-
// shuffle the unassigned shards, just so we won't have things like poison failed shards
121-
routingNodes.unassigned().shuffle();
122120
RoutingAllocation allocation = new RoutingAllocation(
123121
allocationDeciders,
124122
routingNodes,
@@ -197,8 +195,6 @@ public ClusterState applyFailedShards(
197195
ClusterState tmpState = IndexMetadataUpdater.removeStaleIdsWithoutRoutings(clusterState, staleShards, logger);
198196

199197
RoutingNodes routingNodes = getMutableRoutingNodes(tmpState);
200-
// shuffle the unassigned shards, just so we won't have things like poison failed shards
201-
routingNodes.unassigned().shuffle();
202198
long currentNanoTime = currentNanoTime();
203199
RoutingAllocation allocation = new RoutingAllocation(
204200
allocationDeciders,
@@ -274,8 +270,6 @@ public ClusterState applyFailedShards(
274270
*/
275271
public ClusterState disassociateDeadNodes(ClusterState clusterState, boolean reroute, String reason) {
276272
RoutingNodes routingNodes = getMutableRoutingNodes(clusterState);
277-
// shuffle the unassigned shards, just so we won't have things like poison failed shards
278-
routingNodes.unassigned().shuffle();
279273
RoutingAllocation allocation = new RoutingAllocation(
280274
allocationDeciders,
281275
routingNodes,
@@ -479,8 +473,6 @@ public ClusterState reroute(ClusterState clusterState, String reason) {
479473
ClusterState fixedClusterState = adaptAutoExpandReplicas(clusterState);
480474

481475
RoutingNodes routingNodes = getMutableRoutingNodes(fixedClusterState);
482-
// shuffle the unassigned shards, just so we won't have things like poison failed shards
483-
routingNodes.unassigned().shuffle();
484476
RoutingAllocation allocation = new RoutingAllocation(
485477
allocationDeciders,
486478
routingNodes,

0 commit comments

Comments
 (0)