[Bug][Colocate] when adding a table to the colocate group, we should check that the number of buckets per partition is the same (#21906)

for example

CREATE TABLE `colocate_a` (
 dt date,
 k1 int,
 v1 int
) ENGINE=OLAP
DUPLICATE KEY(`k1`)
PARTITION BY RANGE(`dt`)
(PARTITION p1 VALUES [('2022-10-02'), ('2022-10-03'))
DISTRIBUTED BY HASH(`k1`) BUCKETS 2
PROPERTIES (
"replication_num" = "3",
"in_memory" = "false",
"storage_format" = "V2"
);

ALTER TABLE colocate_a set ("colocate_with" = "ab");

CREATE TABLE `colocate_b` (
 dt date,
 k1 int,
 v1 int
) ENGINE=OLAP
DUPLICATE KEY(`k1`)
PARTITION BY RANGE(`dt`)
(PARTITION p1 VALUES [('2022-10-02'), ('2022-10-03'))
DISTRIBUTED BY HASH(`k1`) BUCKETS 2
PROPERTIES (
"replication_num" = "3",
"in_memory" = "false",
"storage_format" = "V2"
);

ALTER TABLE colocate_b ADD PARTITION p2 VALUES [("2022-10-03"),("2022-10-04")) DISTRIBUTED BY HASH(k1) BUCKETS 10;

ALTER TABLE colocate_b set ("colocate_with" = "ab");
table colocate_b partition p2 set bucket num is 10 then take it into group ab.

In ColocateTableCheckerAndBalancer matchGroup occur :

java.lang.IllegalStateException: 2 vs. 10
303861     at com.google.common.base.Preconditions.checkState(Preconditions.java:508) ~[guava-30.0-jre.jar:?]
303862     at org.apache.doris.clone.ColocateTableCheckerAndBalancer.matchGroup(ColocateTableCheckerAndBalancer.java:242) ~[doris-fe.jar:1.2-SNAPSHOT]
303863     at org.apache.doris.clone.ColocateTableCheckerAndBalancer.runAfterCatalogReady(ColocateTableCheckerAndBalancer.java:95) ~[doris-fe.jar:1.2-SNAPSHOT]
303864     at org.apache.doris.common.util.MasterDaemon.runOneCycle(MasterDaemon.java:58) ~[doris-fe.jar:1.2-SNAPSHOT]
303865     at org.apache.doris.common.util.Daemon.run(Daemon.java:116) ~[doris-fe.jar:1.2-SNAPSHOT]
---------

Co-authored-by: shizhiqiang03 <shizhiqiang03@meituan.com>
This commit is contained in:
shee
2023-07-24 09:01:16 +08:00
committed by GitHub
parent d0219062ef
commit ff9811fa1b

View File

@ -72,6 +72,11 @@ public class ColocateGroupSchema implements Writable {
public void checkColocateSchema(OlapTable tbl) throws DdlException {
checkDistribution(tbl.getDefaultDistributionInfo());
// We add a table with many partitions to the colocate group,
// we need to check whether all partitions comply with the colocate group specification
for (Partition partition : tbl.getAllPartitions()) {
checkDistribution(partition.getDistributionInfo());
}
checkReplicaAllocation(tbl.getPartitionInfo());
}