Skip to content

Commit

Permalink
2
Browse files Browse the repository at this point in the history
  • Loading branch information
Yukang-Lian committed Jan 3, 2024
1 parent ecbf5d2 commit f73eb59
Show file tree
Hide file tree
Showing 3 changed files with 143 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public class PropertyAnalyzer {
public static final int PROPERTIES_GROUP_COMMIT_INTERVAL_MS_DEFAULT_VALUE
= Config.group_commit_interval_ms_default_value;

public static final String PROPERTIES_GROUP_COMMIT_DATA_BYTES= "group_commit_data_bytes";
public static final String PROPERTIES_GROUP_COMMIT_DATA_BYTES = "group_commit_data_bytes";
public static final int PROPERTIES_GROUP_COMMIT_DATA_BYTES_DEFAULT_VALUE
= Config.group_commit_data_bytes_default_value;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ public void testDecimal() throws Exception {
+ "\"light_schema_change\" = \"true\",\n"
+ "\"disable_auto_compaction\" = \"false\",\n"
+ "\"enable_single_replica_compaction\" = \"false\",\n"
+ "\"group_commit_interval_ms\" = \"10000\"\n"
+ "\"group_commit_interval_ms\" = \"10000\",\n"
+ "\"group_commit_data_bytes\" = \"134217728\"\n"
+ ");",
showCreateTableByName("select_decimal_table").getResultRows().get(0).get(1));
String selectFromDecimal1 =
Expand All @@ -121,7 +122,8 @@ public void testDecimal() throws Exception {
+ "\"light_schema_change\" = \"true\",\n"
+ "\"disable_auto_compaction\" = \"false\",\n"
+ "\"enable_single_replica_compaction\" = \"false\",\n"
+ "\"group_commit_interval_ms\" = \"10000\"\n"
+ "\"group_commit_interval_ms\" = \"10000\",\n"
+ "\"group_commit_data_bytes\" = \"134217728\"\n"
+ ");",
showCreateTableByName("select_decimal_table_1").getResultRows().get(0).get(1));
} else {
Expand All @@ -140,7 +142,8 @@ public void testDecimal() throws Exception {
+ "\"light_schema_change\" = \"true\",\n"
+ "\"disable_auto_compaction\" = \"false\",\n"
+ "\"enable_single_replica_compaction\" = \"false\",\n"
+ "\"group_commit_interval_ms\" = \"10000\"\n"
+ "\"group_commit_interval_ms\" = \"10000\",\n"
+ "\"group_commit_data_bytes\" = \"134217728\"\n"
+ ");",
showCreateTableByName("select_decimal_table_1").getResultRows().get(0).get(1));
}
Expand Down Expand Up @@ -177,7 +180,8 @@ public void testVarchar() throws Exception {
+ "\"light_schema_change\" = \"true\",\n"
+ "\"disable_auto_compaction\" = \"false\",\n"
+ "\"enable_single_replica_compaction\" = \"false\",\n"
+ "\"group_commit_interval_ms\" = \"10000\"\n"
+ "\"group_commit_interval_ms\" = \"10000\",\n"
+ "\"group_commit_data_bytes\" = \"134217728\"\n"
+ ");",
showResultSet.getResultRows().get(0).get(1));
}
Expand All @@ -203,7 +207,8 @@ public void testFunction() throws Exception {
+ "\"light_schema_change\" = \"true\",\n"
+ "\"disable_auto_compaction\" = \"false\",\n"
+ "\"enable_single_replica_compaction\" = \"false\",\n"
+ "\"group_commit_interval_ms\" = \"10000\"\n"
+ "\"group_commit_interval_ms\" = \"10000\",\n"
+ "\"group_commit_data_bytes\" = \"134217728\"\n"
+ ");",
showResultSet1.getResultRows().get(0).get(1));

Expand Down Expand Up @@ -231,7 +236,8 @@ public void testFunction() throws Exception {
+ "\"light_schema_change\" = \"true\",\n"
+ "\"disable_auto_compaction\" = \"false\",\n"
+ "\"enable_single_replica_compaction\" = \"false\",\n"
+ "\"group_commit_interval_ms\" = \"10000\"\n"
+ "\"group_commit_interval_ms\" = \"10000\",\n"
+ "\"group_commit_data_bytes\" = \"134217728\"\n"
+ ");",
showResultSet2.getResultRows().get(0).get(1));
}
Expand All @@ -256,7 +262,8 @@ public void testAlias() throws Exception {
+ "\"light_schema_change\" = \"true\",\n"
+ "\"disable_auto_compaction\" = \"false\",\n"
+ "\"enable_single_replica_compaction\" = \"false\",\n"
+ "\"group_commit_interval_ms\" = \"10000\"\n"
+ "\"group_commit_interval_ms\" = \"10000\",\n"
+ "\"group_commit_data_bytes\" = \"134217728\"\n"
+ ");", showResultSet1.getResultRows().get(0).get(1));
String selectAlias2 = "create table `test`.`select_alias_2` PROPERTIES(\"replication_num\" = \"1\") "
+ "as select userId as alias_name, username from `test`.`varchar_table`";
Expand All @@ -277,7 +284,8 @@ public void testAlias() throws Exception {
+ "\"light_schema_change\" = \"true\",\n"
+ "\"disable_auto_compaction\" = \"false\",\n"
+ "\"enable_single_replica_compaction\" = \"false\",\n"
+ "\"group_commit_interval_ms\" = \"10000\"\n"
+ "\"group_commit_interval_ms\" = \"10000\",\n"
+ "\"group_commit_data_bytes\" = \"134217728\"\n"
+ ");",
showResultSet2.getResultRows().get(0).get(1));
}
Expand Down Expand Up @@ -305,7 +313,8 @@ public void testJoin() throws Exception {
+ "\"light_schema_change\" = \"true\",\n"
+ "\"disable_auto_compaction\" = \"false\",\n"
+ "\"enable_single_replica_compaction\" = \"false\",\n"
+ "\"group_commit_interval_ms\" = \"10000\"\n"
+ "\"group_commit_interval_ms\" = \"10000\",\n"
+ "\"group_commit_data_bytes\" = \"134217728\"\n"
+ ");",
showResultSet.getResultRows().get(0).get(1));
String selectFromJoin1 = "create table `test`.`select_join1` PROPERTIES(\"replication_num\" = \"1\") "
Expand All @@ -330,7 +339,8 @@ public void testJoin() throws Exception {
+ "\"light_schema_change\" = \"true\",\n"
+ "\"disable_auto_compaction\" = \"false\",\n"
+ "\"enable_single_replica_compaction\" = \"false\",\n"
+ "\"group_commit_interval_ms\" = \"10000\"\n"
+ "\"group_commit_interval_ms\" = \"10000\",\n"
+ "\"group_commit_data_bytes\" = \"134217728\"\n"
+ ");",
showResultSet1.getResultRows().get(0).get(1));
}
Expand Down Expand Up @@ -359,7 +369,8 @@ public void testName() throws Exception {
+ "\"light_schema_change\" = \"true\",\n"
+ "\"disable_auto_compaction\" = \"false\",\n"
+ "\"enable_single_replica_compaction\" = \"false\",\n"
+ "\"group_commit_interval_ms\" = \"10000\"\n"
+ "\"group_commit_interval_ms\" = \"10000\",\n"
+ "\"group_commit_data_bytes\" = \"134217728\"\n"
+ ");",
showResultSet.getResultRows().get(0).get(1));
}
Expand All @@ -385,7 +396,8 @@ public void testUnion() throws Exception {
+ "\"light_schema_change\" = \"true\",\n"
+ "\"disable_auto_compaction\" = \"false\",\n"
+ "\"enable_single_replica_compaction\" = \"false\",\n"
+ "\"group_commit_interval_ms\" = \"10000\"\n"
+ "\"group_commit_interval_ms\" = \"10000\",\n"
+ "\"group_commit_data_bytes\" = \"134217728\"\n"
+ ");", showResultSet.getResultRows().get(0).get(1));
}

Expand All @@ -410,7 +422,8 @@ public void testCte() throws Exception {
+ "\"light_schema_change\" = \"true\",\n"
+ "\"disable_auto_compaction\" = \"false\",\n"
+ "\"enable_single_replica_compaction\" = \"false\",\n"
+ "\"group_commit_interval_ms\" = \"10000\"\n"
+ "\"group_commit_interval_ms\" = \"10000\",\n"
+ "\"group_commit_data_bytes\" = \"134217728\"\n"
+ ");",
showResultSet.getResultRows().get(0).get(1));
String selectFromCteAndUnion = "create table `test`.`select_cte_union` PROPERTIES(\"replication_num\" = \"1\")"
Expand All @@ -431,7 +444,8 @@ public void testCte() throws Exception {
+ "\"light_schema_change\" = \"true\",\n"
+ "\"disable_auto_compaction\" = \"false\",\n"
+ "\"enable_single_replica_compaction\" = \"false\",\n"
+ "\"group_commit_interval_ms\" = \"10000\"\n"
+ "\"group_commit_interval_ms\" = \"10000\",\n"
+ "\"group_commit_data_bytes\" = \"134217728\"\n"
+ ");", showResultSet1.getResultRows().get(0).get(1));
}

Expand Down Expand Up @@ -459,7 +473,8 @@ public void testPartition() throws Exception {
+ "\"light_schema_change\" = \"true\",\n"
+ "\"disable_auto_compaction\" = \"false\",\n"
+ "\"enable_single_replica_compaction\" = \"false\",\n"
+ "\"group_commit_interval_ms\" = \"10000\"\n"
+ "\"group_commit_interval_ms\" = \"10000\",\n"
+ "\"group_commit_data_bytes\" = \"134217728\"\n"
+ ");",
showResultSet.getResultRows().get(0).get(1));
}
Expand All @@ -486,7 +501,8 @@ public void testDefaultTimestamp() throws Exception {
+ "\"light_schema_change\" = \"true\",\n"
+ "\"disable_auto_compaction\" = \"false\",\n"
+ "\"enable_single_replica_compaction\" = \"false\",\n"
+ "\"group_commit_interval_ms\" = \"10000\"\n"
+ "\"group_commit_interval_ms\" = \"10000\",\n"
+ "\"group_commit_data_bytes\" = \"134217728\"\n"
+ ");",
showResultSet.getResultRows().get(0).get(1));
}
Expand All @@ -512,7 +528,8 @@ public void testAggValue() throws Exception {
+ "\"light_schema_change\" = \"true\",\n"
+ "\"disable_auto_compaction\" = \"false\",\n"
+ "\"enable_single_replica_compaction\" = \"false\",\n"
+ "\"group_commit_interval_ms\" = \"10000\"\n"
+ "\"group_commit_interval_ms\" = \"10000\",\n"
+ "\"group_commit_data_bytes\" = \"134217728\"\n"
+ ");",
showResultSet.getResultRows().get(0).get(1));
}
Expand Down Expand Up @@ -540,7 +557,8 @@ public void testUseKeyType() throws Exception {
+ "\"light_schema_change\" = \"true\",\n"
+ "\"disable_auto_compaction\" = \"false\",\n"
+ "\"enable_single_replica_compaction\" = \"false\",\n"
+ "\"group_commit_interval_ms\" = \"10000\"\n"
+ "\"group_commit_interval_ms\" = \"10000\",\n"
+ "\"group_commit_data_bytes\" = \"134217728\"\n"
+ ");",
showResultSet.getResultRows().get(0).get(1));
}
Expand Down Expand Up @@ -591,7 +609,8 @@ public void testQuerySchema() throws Exception {
+ "\"light_schema_change\" = \"true\",\n"
+ "\"disable_auto_compaction\" = \"false\",\n"
+ "\"enable_single_replica_compaction\" = \"false\",\n"
+ "\"group_commit_interval_ms\" = \"10000\"\n"
+ "\"group_commit_interval_ms\" = \"10000\",\n"
+ "\"group_commit_data_bytes\" = \"134217728\"\n"
+ ");",
createTableStmts.get(0));
} else {
Expand All @@ -610,7 +629,8 @@ public void testQuerySchema() throws Exception {
+ "\"light_schema_change\" = \"true\",\n"
+ "\"disable_auto_compaction\" = \"false\",\n"
+ "\"enable_single_replica_compaction\" = \"false\",\n"
+ "\"group_commit_interval_ms\" = \"10000\"\n"
+ "\"group_commit_interval_ms\" = \"10000\",\n"
+ "\"group_commit_data_bytes\" = \"134217728\"\n"
+ ");",
createTableStmts.get(0));
}
Expand Down Expand Up @@ -643,7 +663,8 @@ public void testVarcharLength() throws Exception {
+ "\"light_schema_change\" = \"true\",\n"
+ "\"disable_auto_compaction\" = \"false\",\n"
+ "\"enable_single_replica_compaction\" = \"false\",\n"
+ "\"group_commit_interval_ms\" = \"10000\"\n"
+ "\"group_commit_interval_ms\" = \"10000\",\n"
+ "\"group_commit_data_bytes\" = \"134217728\"\n"
+ ");",
showStr);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

import com.mysql.cj.jdbc.StatementImpl
import org.codehaus.groovy.runtime.IOGroovyMethods

suite("test_group_commit_data_bytes_property") {

def dbName = "regression_test_insert_p0"
def tableName = "test_group_commit_data_bytes_property_tbl"
def table = dbName + "." + tableName

def group_commit_insert = { sql, expected_row_count ->
def stmt = prepareStatement """ ${sql} """
def result = stmt.executeUpdate()
logger.info("insert result: " + result)
def serverInfo = (((StatementImpl) stmt).results).getServerInfo()
logger.info("result server info: " + serverInfo)
if (result != expected_row_count) {
logger.warn("insert result: " + result + ", expected_row_count: " + expected_row_count + ", sql: " + sql)
}
// assertEquals(result, expected_row_count)
assertTrue(serverInfo.contains("'status':'PREPARE'"))
assertTrue(serverInfo.contains("'label':'group_commit_"))
return serverInfo
}



for (item in ["legacy", "nereids"]) {
try {
test_table = table + "_" + item;
sql """ drop table if exists ${test_table} force; """
sql """
CREATE table ${test_table} (
k bigint,
v bigint
)
UNIQUE KEY(k)
DISTRIBUTED BY HASH (v) BUCKETS 8
PROPERTIES(
"replication_num" = "1",
"group_commit_data_bytes"="1024"
);
"""

connect(user = context.config.jdbcUser, password = context.config.jdbcPassword, url = context.config.jdbcUrl) {

sql """ set group_commit = async_mode; """

if (item == "nereids") {
sql """ set enable_nereids_dml = true; """
sql """ set enable_nereids_planner=true; """
//sql """ set enable_fallback_to_original_planner=false; """
} else {
sql """ set enable_nereids_dml = false; """
}

def res1 = sql """show create table ${test_table}"""
assertTrue(res1.toString().contains("\"group_commit_data_bytes\" = \"1024\""))

def msg1 = group_commit_insert """insert into ${test_table} values(1,1); """, 1

def msg2 = group_commit_insert """insert into ${test_table} values(2,2) """, 1

assertEquals(msg1.substring(msg1.indexOf("group_commit")+11, msg1.indexOf("group_commit")+43), msg2.substring(msg2.indexOf("group_commit")+11, msg2.indexOf("group_commit")+43));

sql "ALTER table ${test_table} SET (\"group_commit_data_bytes\"=\"1\"); "

sleep(10000)

def res2 = sql """show create table ${test_table}"""
assertTrue(res2.toString().contains("\"group_commit_data_bytes\" = \"1\""))

def msg3 = group_commit_insert """insert into ${test_table} values(3,3); """, 1

def msg4 = group_commit_insert """insert into ${test_table} values(4,4); """, 1

assertNotEquals(msg3.substring(msg3.indexOf("group_commit")+11, msg3.indexOf("group_commit")+43), msg4.substring(msg4.indexOf("group_commit")+11, msg4.indexOf("group_commit")+43));

}
} finally {
// try_sql("DROP TABLE ${table}")
}
}
}

0 comments on commit f73eb59

Please sign in to comment.