This is an automated email from the ASF dual-hosted git repository. dataroaring pushed a commit to branch branch-2.1 in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.1 by this push: new 9c896efe0b3 [fix](race) fix access colocate group ids race #36444 (#36501) 9c896efe0b3 is described below commit 9c896efe0b319aa599cde69f11bb61944f9a9509 Author: yujun <yu.jun.re...@gmail.com> AuthorDate: Wed Jun 19 15:38:50 2024 +0800 [fix](race) fix access colocate group ids race #36444 (#36501) cherry pick from #36444 --- .../org/apache/doris/catalog/ColocateTableIndex.java | 2 +- .../doris/clone/ColocateTableCheckerAndBalancer.java | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/ColocateTableIndex.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/ColocateTableIndex.java index fcefcff132a..470464407d0 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/catalog/ColocateTableIndex.java +++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/ColocateTableIndex.java @@ -429,7 +429,7 @@ public class ColocateTableIndex implements Writable { public Set<GroupId> getAllGroupIds() { readLock(); try { - return group2Tables.keySet(); + return Sets.newHashSet(group2Tables.keySet()); } finally { readUnlock(); } diff --git a/fe/fe-core/src/main/java/org/apache/doris/clone/ColocateTableCheckerAndBalancer.java b/fe/fe-core/src/main/java/org/apache/doris/clone/ColocateTableCheckerAndBalancer.java index 740acd331c3..292013ec05a 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/clone/ColocateTableCheckerAndBalancer.java +++ b/fe/fe-core/src/main/java/org/apache/doris/clone/ColocateTableCheckerAndBalancer.java @@ -378,7 +378,7 @@ public class ColocateTableCheckerAndBalancer extends MasterDaemon { * A B C D */ private void relocateAndBalanceGroups() { - Set<GroupId> groupIds = Sets.newHashSet(Env.getCurrentEnv().getColocateTableIndex().getAllGroupIds()); + Set<GroupId> groupIds = Env.getCurrentEnv().getColocateTableIndex().getAllGroupIds(); // balance only inside each group, excluded balance between all groups Set<GroupId> changeGroups = relocateAndBalanceGroup(groupIds, false); @@ -410,6 +410,10 @@ public class ColocateTableCheckerAndBalancer extends MasterDaemon { } ColocateGroupSchema groupSchema = colocateIndex.getGroupSchema(groupId); + if (groupSchema == null) { + LOG.info("Not found colocate group {}, maybe delete", groupId); + continue; + } ReplicaAllocation replicaAlloc = groupSchema.getReplicaAlloc(); try { Env.getCurrentSystemInfo().checkReplicaAllocation(replicaAlloc); @@ -480,13 +484,18 @@ public class ColocateTableCheckerAndBalancer extends MasterDaemon { // check each group Set<GroupId> groupIds = colocateIndex.getAllGroupIds(); for (GroupId groupId : groupIds) { + ColocateGroupSchema groupSchema = colocateIndex.getGroupSchema(groupId); + if (groupSchema == null) { + LOG.info("Not found colocate group {}, maybe delete", groupId); + continue; + } + List<Long> tableIds = colocateIndex.getAllTableIds(groupId); List<Set<Long>> backendBucketsSeq = colocateIndex.getBackendsPerBucketSeqSet(groupId); if (backendBucketsSeq.isEmpty()) { continue; } - ColocateGroupSchema groupSchema = colocateIndex.getGroupSchema(groupId); ReplicaAllocation replicaAlloc = groupSchema.getReplicaAlloc(); String unstableReason = null; OUT: @@ -588,6 +597,7 @@ public class ColocateTableCheckerAndBalancer extends MasterDaemon { for (GroupId groupId : groupIds) { ColocateGroupSchema groupSchema = colocateIndex.getGroupSchema(groupId); if (groupSchema == null) { + LOG.info("Not found colocate group {}, maybe delete", groupId); continue; } ReplicaAllocation replicaAlloc = groupSchema.getReplicaAlloc(); @@ -718,6 +728,10 @@ public class ColocateTableCheckerAndBalancer extends MasterDaemon { GlobalColocateStatistic globalColocateStatistic, List<List<Long>> balancedBackendsPerBucketSeq, boolean balanceBetweenGroups) { ColocateGroupSchema groupSchema = colocateIndex.getGroupSchema(groupId); + if (groupSchema == null) { + LOG.info("Not found colocate group {}, maybe delete", groupId); + return false; + } short replicaNum = groupSchema.getReplicaAlloc().getReplicaNumByTag(tag); List<List<Long>> backendsPerBucketSeq = Lists.newArrayList( colocateIndex.getBackendsPerBucketSeqByTag(groupId, tag)); --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org