From fbb32e76357e583cef31d184e62e0eb2de5eeefd Mon Sep 17 00:00:00 2001 From: yujun Date: Wed, 5 Jun 2024 08:53:05 +0800 Subject: [PATCH] [fix](regression test) test_alter_colocate_group due to force_olap_table_replication_num (#35835) ``` Exception in alter_p2/test_alter_colocate_group.groovy(line 94): ) DISTRIBUTED BY HASH(k2) BUCKETS 5 PROPERTIES ( "colocate_with" = "group_2", "replication_num" = "1" ); """ sql """ ^^^^^^^^^^^^^^^^^^^^^^^^^ERROR LINE^^^^^^^^^^^^^^^^^^^^^^^^^ CREATE TABLE tbl3 ( `uuid` varchar(255) NULL, `action_datetime` date NULL ) DUPLICATE KEY(uuid) PARTITION BY RANGE(action_datetime)() DISTRIBUTED BY HASH(uuid) BUCKETS 4 PROPERTIES ( Exception: java.sql.SQLSyntaxErrorException: Colocate tables must have same replication allocation: { tag.location.default: 1 } should be { tag.location.default: 3 } at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:120) ``` --- .../alter_p2/test_alter_colocate_group.groovy | 42 +++++++++++++------ 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/regression-test/suites/alter_p2/test_alter_colocate_group.groovy b/regression-test/suites/alter_p2/test_alter_colocate_group.groovy index 94ca9f24d6de00..1b36e7242d67bf 100644 --- a/regression-test/suites/alter_p2/test_alter_colocate_group.groovy +++ b/regression-test/suites/alter_p2/test_alter_colocate_group.groovy @@ -58,6 +58,12 @@ suite ("test_alter_colocate_group") { sql " DROP TABLE IF EXISTS tbl2 FORCE; " sql " DROP TABLE IF EXISTS tbl3 FORCE; " + def replication_num = 1 + def forceReplicaNum = getFeConfig('force_olap_table_replication_num').toInteger() + if (forceReplicaNum > 0) { + replication_num = forceReplicaNum + } + sql """ CREATE TABLE tbl1 ( @@ -68,7 +74,7 @@ suite ("test_alter_colocate_group") { PROPERTIES ( "colocate_with" = "group_1", - "replication_num" = "1" + "replication_num" = "${replication_num}" ); """ @@ -87,7 +93,7 @@ suite ("test_alter_colocate_group") { PROPERTIES ( "colocate_with" = "group_2", - "replication_num" = "1" + "replication_num" = "${replication_num}" ); """ @@ -103,13 +109,13 @@ suite ("test_alter_colocate_group") { PROPERTIES ( "colocate_with" = "group_3", - "replication_num" = "1", + "replication_num" = "${replication_num}", "dynamic_partition.enable" = "true", "dynamic_partition.time_unit" = "DAY", "dynamic_partition.end" = "2", "dynamic_partition.prefix" = "p", "dynamic_partition.buckets" = "4", - "dynamic_partition.replication_num" = "1" + "dynamic_partition.replication_num" = "${replication_num}" ); """ @@ -140,6 +146,16 @@ suite ("test_alter_colocate_group") { } } + def beNum = sql_return_maparray("show backends").size() + def modifyReplicaNum = -1 + for (int i=1; i <= beNum; i++) { + if (i != replication_num) { + modifyReplicaNum = i + break + } + } + logger.info("old replica num ${replication_num}, modify replica num ${modifyReplicaNum}") + for (int i = 1; i <= 3; i++) { def groupName = "regression_test_alter_p2.group_${i}" checkGroupsReplicaAlloc(groupName, 1) @@ -157,15 +173,17 @@ suite ("test_alter_colocate_group") { exception "Failed to find enough host" } - test { - sql """ - ALTER COLOCATE GROUP ${groupName} - SET ( "replication_num" = "3" ); - """ - } + if (modifyReplicaNum > 0) { + test { + sql """ + ALTER COLOCATE GROUP ${groupName} + SET ( "replication_num" = "${modifyReplicaNum}" ); + """ + } - checkGroupsReplicaAlloc(groupName, 3) - checkTableReplicaAlloc(tableName, hasDynamicPart, 3) + checkGroupsReplicaAlloc(groupName, modifyReplicaNum) + checkTableReplicaAlloc(tableName, hasDynamicPart, modifyReplicaNum) + } } sql " DROP TABLE IF EXISTS tbl1 FORCE; "