diff --git a/fe/fe-core/src/main/java/com/starrocks/clone/DiskAndTabletLoadReBalancer.java b/fe/fe-core/src/main/java/com/starrocks/clone/DiskAndTabletLoadReBalancer.java index ce581bf7f2a63..a77276cb9d451 100644 --- a/fe/fe-core/src/main/java/com/starrocks/clone/DiskAndTabletLoadReBalancer.java +++ b/fe/fe-core/src/main/java/com/starrocks/clone/DiskAndTabletLoadReBalancer.java @@ -554,6 +554,10 @@ private List balanceClusterDisk(ClusterLoadStatistic clusterStat continue; } + if (!olapTable.needSchedule(false)) { + continue; + } + if (isDestBackendLocationMismatch(olapTable, hBackend.getId(), lBackend.getId(), physicalPartition.getParentId(), tabletId)) { continue; @@ -742,8 +746,8 @@ private void balanceBackendDisk(TStorageMedium medium, double avgUsedPercent, long destPathHash = pathStats.get(destPathIndex).getPathHash(); // (partition, index) => tabletIds - Map, Set> srcPathPartitionTablets = getPartitionTablets(beId, medium, srcPathHash); - Map, Set> destPathPartitionTablets = getPartitionTablets(beId, medium, destPathHash); + Map, Set> srcPathPartitionTablets = getPartitionTablets(beId, medium, srcPathHash, true); + Map, Set> destPathPartitionTablets = getPartitionTablets(beId, medium, destPathHash, true); Map, PartitionStat> partitionStats = getPartitionStats(medium, true, null, null); boolean srcChanged = false; @@ -755,13 +759,13 @@ private void balanceBackendDisk(TStorageMedium medium, double avgUsedPercent, if (srcChanged) { srcPathUsedCap = srcPathStat.getUsedCapacityB(); srcPathHash = srcPathStat.getPathHash(); - srcPathPartitionTablets = getPartitionTablets(beId, medium, srcPathHash); + srcPathPartitionTablets = getPartitionTablets(beId, medium, srcPathHash, true); srcChanged = false; } if (destChanged) { destPathUsedCap = destPathStat.getUsedCapacityB(); destPathHash = destPathStat.getPathHash(); - destPathPartitionTablets = getPartitionTablets(beId, medium, destPathHash); + destPathPartitionTablets = getPartitionTablets(beId, medium, destPathHash, true); destChanged = false; } @@ -962,7 +966,8 @@ private boolean isTabletExistsInBackends(Long tabletId, List backends) { /** * @return map : (physical partition id, index) => tablets */ - private Map, Set> getPartitionTablets(long beId, TStorageMedium medium, long pathHash) { + private Map, Set> getPartitionTablets(long beId, TStorageMedium medium, long pathHash, + boolean isLocalBalance) { Map, Set> partitionTablets = Maps.newHashMap(); List tabletIds = GlobalStateMgr.getCurrentState().getTabletInvertedIndex().getTabletIdsByBackendIdAndStorageMedium(beId, medium); @@ -984,6 +989,11 @@ private Map, Set> getPartitionTablets(long beId, TStorage } } + OlapTable olapTable = getOlapTableById(tabletMeta.getDbId(), tabletMeta.getTableId()); + if (olapTable != null && !olapTable.needSchedule(isLocalBalance)) { + continue; + } + Pair key = new Pair<>(tabletMeta.getPhysicalPartitionId(), tabletMeta.getIndexId()); partitionTablets.computeIfAbsent(key, k -> Sets.newHashSet()).add(tabletId); } @@ -1465,6 +1475,10 @@ private List>> getPartitionTablets(Long dbId, Long tableId, if (table == null) { return result; } + if (!table.needSchedule(beIds == null)) { + return result; + } + if (table.isCloudNativeTableOrMaterializedView()) { // replicas are managed by StarOS and cloud storage. return result; @@ -1826,7 +1840,7 @@ private BackendBalanceState getBackendBalanceState(long backendId, Map partitionReplicaCnt, int backendCnt, boolean sortPartition) { - Map, Set> physicalPartitionTablets = getPartitionTablets(backendId, medium, -1L); + Map, Set> physicalPartitionTablets = getPartitionTablets(backendId, medium, -1L, false); Map, List> partitionTabletList = new HashMap<>(); for (Map.Entry, Set> entry : physicalPartitionTablets.entrySet()) { partitionTabletList.put(entry.getKey(), new LinkedList<>(entry.getValue()));