Skip to content

Commit 9f34099

Browse files
howardhuanghuahenningandersen
authored andcommitted
Only check replicas in cancelling existing recoveries. (#60564)
Minor performance improvement when only primaries are initializing.
1 parent 2e405af commit 9f34099

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
@@ -118,7 +118,7 @@ public void beforeAllocation(final RoutingAllocation allocation) {
118118
@Override
119119
public void afterPrimariesBeforeReplicas(RoutingAllocation allocation) {
120120
assert replicaShardAllocator != null;
121-
if (allocation.routingNodes().hasInactiveShards()) {
121+
if (allocation.routingNodes().hasInactiveReplicas()) {
122122
// cancel existing recoveries if we have a better match
123123
replicaShardAllocator.processExistingRecoveries(allocation);
124124
}

0 commit comments

Comments
 (0)