From 3202dc28e899c5c525f228f708c75404b2bbfe0b Mon Sep 17 00:00:00 2001 From: Mingyu Chen Date: Tue, 9 Jul 2019 10:38:35 +0800 Subject: [PATCH] Fix bug that unable to delete redundant replicas (#1442) This can happen if the Doris cluster is deployed with all, for example, SSD medium, but create all tables with HDD storage medium property. Then getLoadScore(SSD) will always return 0.0, so that no replica will be chosen when try to delete redundant replicas. --- .../apache/doris/clone/TabletScheduler.java | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/fe/src/main/java/org/apache/doris/clone/TabletScheduler.java b/fe/src/main/java/org/apache/doris/clone/TabletScheduler.java index 3796289978..b3c3de10c6 100644 --- a/fe/src/main/java/org/apache/doris/clone/TabletScheduler.java +++ b/fe/src/main/java/org/apache/doris/clone/TabletScheduler.java @@ -772,8 +772,23 @@ public class TabletScheduler extends Daemon { if (beStatistic == null) { continue; } - if (beStatistic.getLoadScore(tabletCtx.getStorageMedium()) > maxScore) { - maxScore = beStatistic.getLoadScore(tabletCtx.getStorageMedium()); + + /* + * If the backend does not have the specified storage medium, we use mix load score to make + * sure that at least one replica can be chosen. + * This can happen if the Doris cluster is deployed with all, for example, SSD medium, + * but create all tables with HDD storage medium property. Then getLoadScore(SSD) will + * always return 0.0, so that no replica will be chosen. + */ + double loadScore = 0.0; + if (beStatistic.hasMedium(tabletCtx.getStorageMedium())) { + loadScore = beStatistic.getLoadScore(tabletCtx.getStorageMedium()); + } else { + loadScore = beStatistic.getMixLoadScore(); + } + + if (loadScore > maxScore) { + maxScore = loadScore; chosenReplica = replica; } }