From 3454735eba285d8422ce36bf102612995e2ed63e Mon Sep 17 00:00:00 2001 From: dh-cloud <60729713+dh-cloud@users.noreply.github.com> Date: Tue, 28 Dec 2021 15:03:29 +0800 Subject: [PATCH] [fix](balance) fix partition rebalance bug (#7213) the number of replica on specified medium we get from `getReplicaNumByBeIdAndStorageMedium()` is defined by table properties. But in fact there may not has SSD/HDD disk on this backend. So if we found that no SSD/HDD disk on this backend, set the replica number to 0, but the partitionInfoBySkew doesn't consider this scene, medium has no SSD/HDD disk also skew, cause rebalance exception --- .../clone/TwoDimensionalGreedyRebalanceAlgo.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/fe/fe-core/src/main/java/org/apache/doris/clone/TwoDimensionalGreedyRebalanceAlgo.java b/fe/fe-core/src/main/java/org/apache/doris/clone/TwoDimensionalGreedyRebalanceAlgo.java index cabb5afe17..3db68792d9 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/clone/TwoDimensionalGreedyRebalanceAlgo.java +++ b/fe/fe-core/src/main/java/org/apache/doris/clone/TwoDimensionalGreedyRebalanceAlgo.java @@ -135,6 +135,17 @@ public class TwoDimensionalGreedyRebalanceAlgo { // Nothing to balance: cluster is empty. return Lists.newArrayList(); } + + NavigableSet keySet = info.beByTotalReplicaCount.keySet(); + if (keySet.isEmpty() || keySet.last() == 0L) { + // the number of replica on specified medium we get from getReplicaNumByBeIdAndStorageMedium() is + // defined by table properties,but in fact there may not has SSD/HDD disk on this backend. + // So if we found that no SSD/HDD disk on this backend, set the replica number to 0, + // but the partitionInfoBySkew doesn't consider this scene, medium has no SSD/HDD disk also skew, + // cause rebalance exception + return Lists.newArrayList(); + } + List moves = Lists.newArrayList(); for (int i = 0; i < maxMovesNum; ++i) {