Skip to content

Commit 962e050

Browse files
Only check replicas in cancelling existing recoveries. (#60564)
Minor performance improvement when only primaries are initializing.
1 parent aa2aa9b commit 962e050

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,10 @@ public boolean hasInactivePrimaries() {
267267
return inactivePrimaryCount > 0;
268268
}
269269

270+
public boolean hasInactiveReplicas() {
271+
return inactiveShardCount > inactivePrimaryCount;
272+
}
273+
270274
public boolean hasInactiveShards() {
271275
return inactiveShardCount > 0;
272276
}

server/src/main/java/org/elasticsearch/gateway/GatewayAllocator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public void beforeAllocation(final RoutingAllocation allocation) {
121121
@Override
122122
public void afterPrimariesBeforeReplicas(RoutingAllocation allocation) {
123123
assert replicaShardAllocator != null;
124-
if (allocation.routingNodes().hasInactiveShards()) {
124+
if (allocation.routingNodes().hasInactiveReplicas()) {
125125
// cancel existing recoveries if we have a better match
126126
replicaShardAllocator.processExistingRecoveries(allocation);
127127
}

0 commit comments

Comments
 (0)