Skip to content

Commit

Permalink
[fix](regression test) test_alter_colocate_group due to force_olap_ta…
Browse files Browse the repository at this point in the history
…ble_replication_num (apache#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)
```
  • Loading branch information
yujun777 authored and dataroaring committed Jun 7, 2024
1 parent e0001bc commit fbb32e7
Showing 1 changed file with 30 additions and 12 deletions.
42 changes: 30 additions & 12 deletions regression-test/suites/alter_p2/test_alter_colocate_group.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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
(
Expand All @@ -68,7 +74,7 @@ suite ("test_alter_colocate_group") {
PROPERTIES
(
"colocate_with" = "group_1",
"replication_num" = "1"
"replication_num" = "${replication_num}"
);
"""

Expand All @@ -87,7 +93,7 @@ suite ("test_alter_colocate_group") {
PROPERTIES
(
"colocate_with" = "group_2",
"replication_num" = "1"
"replication_num" = "${replication_num}"
);
"""

Expand All @@ -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}"
);
"""

Expand Down Expand Up @@ -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)
Expand All @@ -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; "
Expand Down

0 comments on commit fbb32e7

Please sign in to comment.