Skip to content
Merged
Show file tree
Hide file tree
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 @@ -4371,8 +4371,10 @@ private void createTablets(String clusterName, MaterializedIndex index, ReplicaS
Preconditions.checkState(chosenBackendIds.size() == replicationNum, chosenBackendIds.size() + " vs. "+ replicationNum);
}

if (groupId != null) {
if (groupId != null && chooseBackendsArbitrary) {
colocateIndex.addBackendsPerBucketSeq(groupId, backendsPerBucketSeq);
ColocatePersistInfo info = ColocatePersistInfo.createForBackendsPerBucketSeq(groupId, backendsPerBucketSeq);
editLog.logColocateBackendsPerBucketSeq(info);
}

} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,11 @@ public GroupId addTableToGroup(long dbId, OlapTable tbl, String groupName, Group
// generate a new one
groupId = new GroupId(dbId, Catalog.getCurrentCatalog().getNextId());
}
groupName2Id.put(fullGroupName, groupId);
HashDistributionInfo distributionInfo = (HashDistributionInfo) tbl.getDefaultDistributionInfo();
ColocateGroupSchema groupSchema = new ColocateGroupSchema(groupId,
distributionInfo.getDistributionColumns(), distributionInfo.getBucketNum(),
tbl.getPartitionInfo().idToReplicationNum.values().stream().findFirst().get());
tbl.getDefaultReplicationNum());
groupName2Id.put(fullGroupName, groupId);
group2Schema.put(groupId, groupSchema);
}
group2Tables.put(groupId, tbl.getId());
Expand Down Expand Up @@ -321,8 +321,12 @@ public Set<Long> getBackendsByGroup(GroupId groupId) {
try {
Set<Long> allBackends = new HashSet<>();
List<List<Long>> backendsPerBucketSeq = group2BackendsPerBucketSeq.get(groupId);
for (List<Long> bes : backendsPerBucketSeq) {
allBackends.addAll(bes);
// if create colocate table with empty partition or create colocate table
// with dynamic_partition will cause backendsPerBucketSeq == null
if (backendsPerBucketSeq != null) {
for (List<Long> bes : backendsPerBucketSeq) {
allBackends.addAll(bes);
}
}
return allBackends;
} finally {
Expand Down Expand Up @@ -446,7 +450,6 @@ public void replayAddTableToGroup(ColocatePersistInfo info) {
writeLock();
try {
if (!group2BackendsPerBucketSeq.containsKey(info.getGroupId())) {
Preconditions.checkState(!info.getBackendsPerBucketSeq().isEmpty());
group2BackendsPerBucketSeq.put(info.getGroupId(), info.getBackendsPerBucketSeq());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@ private void relocateAndBalanceGroup() {
if (statistic == null) {
continue;
}
List<List<Long>> backendsPerBucketSeq = colocateIndex.getBackendsPerBucketSeq(groupId);
if (backendsPerBucketSeq.isEmpty()) {
continue;
}

Set<Long> unavailableBeIdsInGroup = getUnavailableBeIdsInGroup(infoService, colocateIndex, groupId);
List<Long> availableBeIds = getAvailableBeIds(db.getClusterName(), infoService);
Expand Down Expand Up @@ -183,6 +187,10 @@ private void matchGroup() {
}

List<Set<Long>> backendBucketsSeq = colocateIndex.getBackendsPerBucketSeqSet(groupId);
if (backendBucketsSeq.isEmpty()) {
continue;
}

boolean isGroupStable = true;
db.readLock();
try {
Expand Down