Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BugFix] Fix repeated migration of colocate tablets #53099

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,10 @@ private List<TabletSchedCtx> balanceClusterDisk(ClusterLoadStatistic clusterStat
continue;
}

if (!olapTable.needSchedule(false)) {
continue;
}

if (isDestBackendLocationMismatch(olapTable, hBackend.getId(), lBackend.getId(),
physicalPartition.getParentId(), tabletId)) {
continue;
Expand Down Expand Up @@ -742,8 +746,8 @@ private void balanceBackendDisk(TStorageMedium medium, double avgUsedPercent,
long destPathHash = pathStats.get(destPathIndex).getPathHash();

// (partition, index) => tabletIds
Map<Pair<Long, Long>, Set<Long>> srcPathPartitionTablets = getPartitionTablets(beId, medium, srcPathHash);
Map<Pair<Long, Long>, Set<Long>> destPathPartitionTablets = getPartitionTablets(beId, medium, destPathHash);
Map<Pair<Long, Long>, Set<Long>> srcPathPartitionTablets = getPartitionTablets(beId, medium, srcPathHash, true);
Map<Pair<Long, Long>, Set<Long>> destPathPartitionTablets = getPartitionTablets(beId, medium, destPathHash, true);
Map<Pair<Long, Long>, PartitionStat> partitionStats = getPartitionStats(medium, true, null, null);

boolean srcChanged = false;
Expand All @@ -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;
}

Expand Down Expand Up @@ -962,7 +966,8 @@ private boolean isTabletExistsInBackends(Long tabletId, List<Long> backends) {
/**
* @return map : (physical partition id, index) => tablets
*/
private Map<Pair<Long, Long>, Set<Long>> getPartitionTablets(long beId, TStorageMedium medium, long pathHash) {
private Map<Pair<Long, Long>, Set<Long>> getPartitionTablets(long beId, TStorageMedium medium, long pathHash,
boolean isLocalBalance) {
Map<Pair<Long, Long>, Set<Long>> partitionTablets = Maps.newHashMap();
List<Long> tabletIds =
GlobalStateMgr.getCurrentState().getTabletInvertedIndex().getTabletIdsByBackendIdAndStorageMedium(beId, medium);
Expand All @@ -984,6 +989,11 @@ private Map<Pair<Long, Long>, Set<Long>> getPartitionTablets(long beId, TStorage
}
}

OlapTable olapTable = getOlapTableById(tabletMeta.getDbId(), tabletMeta.getTableId());
if (olapTable != null && !olapTable.needSchedule(isLocalBalance)) {
continue;
}

Pair<Long, Long> key = new Pair<>(tabletMeta.getPhysicalPartitionId(), tabletMeta.getIndexId());
partitionTablets.computeIfAbsent(key, k -> Sets.newHashSet()).add(tabletId);
}
Expand Down Expand Up @@ -1465,6 +1475,10 @@ private List<Pair<Long, Set<Long>>> getPartitionTablets(Long dbId, Long tableId,
if (table == null) {
return result;
}
if (!table.needSchedule(beIds == null)) {
return result;
}

gengjun-git marked this conversation as resolved.
Show resolved Hide resolved
if (table.isCloudNativeTableOrMaterializedView()) {
// replicas are managed by StarOS and cloud storage.
return result;
Expand Down Expand Up @@ -1826,7 +1840,7 @@ private BackendBalanceState getBackendBalanceState(long backendId,
Map<Long, Integer> partitionReplicaCnt,
int backendCnt,
boolean sortPartition) {
Map<Pair<Long, Long>, Set<Long>> physicalPartitionTablets = getPartitionTablets(backendId, medium, -1L);
Map<Pair<Long, Long>, Set<Long>> physicalPartitionTablets = getPartitionTablets(backendId, medium, -1L, false);
Map<Pair<Long, Long>, List<Long>> partitionTabletList = new HashMap<>();
for (Map.Entry<Pair<Long, Long>, Set<Long>> entry : physicalPartitionTablets.entrySet()) {
partitionTabletList.put(entry.getKey(), new LinkedList<>(entry.getValue()));
Expand Down
Loading