Skip to content

Commit 3594ade

Browse files
authored
Skip rebalancing for single node per partition (#128167)
If the cluster has 2 nodes in total and 1 node in each partition. Rebalancing can be skipped when it runs per partition. Relates: #126091
1 parent b22452d commit 3594ade

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

server/src/main/java/org/elasticsearch/cluster/routing/allocation/allocator/BalancedShardsAllocator.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -377,13 +377,13 @@ private void balance() {
377377
logger.trace("skipping rebalance as it is disabled");
378378
return;
379379
}
380-
if (nodes.size() < 2) { /* skip if we only have one node */
381-
logger.trace("skipping rebalance as single node only");
382-
return;
383-
}
384380

385381
// Balance each partition
386382
for (NodeSorter nodeSorter : nodeSorters) {
383+
if (nodeSorter.modelNodes.length < 2) { /* skip if we only have one node */
384+
logger.trace("skipping rebalance as the partition has single node only");
385+
continue;
386+
}
387387
balanceByWeights(nodeSorter);
388388
}
389389
}

0 commit comments

Comments
 (0)