Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix](compaction)Fix cluster key column duplicated in value columns group #44610

Merged
merged 3 commits into from
Nov 28, 2024
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
2 changes: 1 addition & 1 deletion be/src/olap/merger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ void Merger::vertical_split_columns(const TabletSchema& tablet_schema,
<< ", delete_sign_idx=" << delete_sign_idx;
// for duplicate no keys
if (!key_columns.empty()) {
column_groups->emplace_back(std::move(key_columns));
column_groups->emplace_back(key_columns);
}

std::vector<uint32_t> value_columns;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,71 @@
2 bason bason hate pear 99
3 bason bason hate pear 99

-- !sql --
1 bason bason hate pear 99
2 bason bason hate pear 99
3 bason bason hate pear 99

-- !sql --

-- !sql --
1 bason bason hate pear 99
2 bason bason hate pear 99
3 bason bason hate pear 99

-- !sql --
1 bason bason hate pear 99
2 bason bason hate pear 99
3 bason bason hate pear 99

-- !sql --
1 bason bason hate pear 99
2 bason bason hate pear 99
3 bason bason hate pear 99

-- !sql --

-- !sql --
1 bason bason hate pear 99
2 bason bason hate pear 99
3 bason bason hate pear 99

-- !sql --
1 bason bason hate pear 99
2 bason bason hate pear 99
3 bason bason hate pear 99

-- !sql --
1 bason bason hate pear 99
2 bason bason hate pear 99
3 bason bason hate pear 99

-- !sql --

-- !sql --
1 bason bason hate pear 99
2 bason bason hate pear 99
3 bason bason hate pear 99

-- !sql --
1 bason bason hate pear 99
2 bason bason hate pear 99
3 bason bason hate pear 99

-- !sql --
1 bason bason hate pear 99
2 bason bason hate pear 99
3 bason bason hate pear 99

-- !sql --

-- !sql --
1 bason bason hate pear 99
2 bason bason hate pear 99
3 bason bason hate pear 99

-- !sql --
1 bason bason hate pear 99
2 bason bason hate pear 99
3 bason bason hate pear 99

Original file line number Diff line number Diff line change
Expand Up @@ -112,69 +112,22 @@ suite("test_index_compaction_unique_keys_arr", "array_contains_inverted_index")
}
}

boolean invertedIndexCompactionEnable = false
boolean has_update_be_config = false
try {
String backend_id;
backend_id = backendId_to_backendIP.keySet()[0]
def (code, out, err) = show_be_config(backendId_to_backendIP.get(backend_id), backendId_to_backendHttpPort.get(backend_id))

logger.info("Show config: code=" + code + ", out=" + out + ", err=" + err)
assertEquals(code, 0)
def configList = parseJson(out.trim())
assert configList instanceof List
def run_test = { table_name ->

for (Object ele in (List) configList) {
assert ele instanceof List<String>
if (((List<String>) ele)[0] == "inverted_index_compaction_enable") {
invertedIndexCompactionEnable = Boolean.parseBoolean(((List<String>) ele)[2])
logger.info("inverted_index_compaction_enable: ${((List<String>) ele)[2]}")
}
if (((List<String>) ele)[0] == "disable_auto_compaction") {
disableAutoCompaction = Boolean.parseBoolean(((List<String>) ele)[2])
logger.info("disable_auto_compaction: ${((List<String>) ele)[2]}")
}
}
set_be_config.call("inverted_index_compaction_enable", "true")
has_update_be_config = true
// check updated config
check_config.call("inverted_index_compaction_enable", "true");
sql """ INSERT INTO ${table_name} VALUES (1, "andy", "andy love apple", 100); """
sql """ INSERT INTO ${table_name} VALUES (1, "bason", "bason hate pear", 99); """
sql """ INSERT INTO ${table_name} VALUES (2, "andy", "andy love apple", 100); """
sql """ INSERT INTO ${table_name} VALUES (2, "bason", "bason hate pear", 99); """
sql """ INSERT INTO ${table_name} VALUES (3, "andy", "andy love apple", 100); """
sql """ INSERT INTO ${table_name} VALUES (3, "bason", "bason hate pear", 99); """

sql """ DROP TABLE IF EXISTS ${tableName}; """
sql """
CREATE TABLE ${tableName} (
`id` int(11) NULL,
`name` varchar(255) NULL,
`hobbies` text NULL,
`score` int(11) NULL,
index index_name (name) using inverted,
index index_hobbies (hobbies) using inverted properties("parser"="english"),
index index_score (score) using inverted
) ENGINE=OLAP
UNIQUE KEY(`id`)
COMMENT 'OLAP'
DISTRIBUTED BY HASH(`id`) BUCKETS 1
PROPERTIES (
"replication_num" = "1",
"disable_auto_compaction" = "true",
"enable_unique_key_merge_on_write" = "true"
);
"""

sql """ INSERT INTO ${tableName} VALUES (1, "andy", "andy love apple", 100); """
sql """ INSERT INTO ${tableName} VALUES (1, "bason", "bason hate pear", 99); """
sql """ INSERT INTO ${tableName} VALUES (2, "andy", "andy love apple", 100); """
sql """ INSERT INTO ${tableName} VALUES (2, "bason", "bason hate pear", 99); """
sql """ INSERT INTO ${tableName} VALUES (3, "andy", "andy love apple", 100); """
sql """ INSERT INTO ${tableName} VALUES (3, "bason", "bason hate pear", 99); """

qt_sql """ select * from ${tableName} order by id, name, hobbies, score """
qt_sql """ select * from ${tableName} where name match "andy" order by id, name, hobbies, score """
qt_sql """ select * from ${tableName} where hobbies match "pear" order by id, name, hobbies, score """
qt_sql """ select * from ${tableName} where score < 100 order by id, name, hobbies, score """
qt_sql """ select * from ${table_name} order by id, name, hobbies, score """
qt_sql """ select * from ${table_name} where name match "andy" order by id, name, hobbies, score """
qt_sql """ select * from ${table_name} where hobbies match "pear" order by id, name, hobbies, score """
qt_sql """ select * from ${table_name} where score < 100 order by id, name, hobbies, score """

//TabletId,ReplicaId,BackendId,SchemaHash,Version,LstSuccessVersion,LstFailedVersion,LstFailedTime,LocalDataSize,RemoteDataSize,RowCount,State,LstConsistencyCheckTime,CheckVersion,VersionCount,PathHash,MetaUrl,CompactionStatus
def tablets = sql_return_maparray """ show tablets from ${tableName}; """
def tablets = sql_return_maparray """ show tablets from ${table_name}; """
def dedup_tablets = deduplicate_tablets(tablets)

// In the p0 testing environment, there are no expected operations such as scaling down BE (backend) services
Expand All @@ -189,7 +142,7 @@ suite("test_index_compaction_unique_keys_arr", "array_contains_inverted_index")
int rowsetCount = get_rowset_count.call(tablets);
assert (rowsetCount == 7 * replicaNum)

// trigger full compactions for all tablets in ${tableName}
// trigger full compactions for all tablets in ${table_name}
trigger_full_compaction_on_tablets.call(tablets)

// wait for full compaction done
Expand All @@ -203,23 +156,23 @@ suite("test_index_compaction_unique_keys_arr", "array_contains_inverted_index")
assert (rowsetCount == 1 * replicaNum)
}

qt_sql """ select * from ${tableName} order by id, name, hobbies, score """
qt_sql """ select * from ${tableName} where name match "andy" order by id, name, hobbies, score """
qt_sql """ select * from ${tableName} where hobbies match "pear" order by id, name, hobbies, score """
qt_sql """ select * from ${tableName} where score < 100 order by id, name, hobbies, score """
qt_sql """ select * from ${table_name} order by id, name, hobbies, score """
qt_sql """ select * from ${table_name} where name match "andy" order by id, name, hobbies, score """
qt_sql """ select * from ${table_name} where hobbies match "pear" order by id, name, hobbies, score """
qt_sql """ select * from ${table_name} where score < 100 order by id, name, hobbies, score """

// insert more data and trigger full compaction again
sql """ INSERT INTO ${tableName} VALUES (1, "andy", "andy love apple", 100); """
sql """ INSERT INTO ${tableName} VALUES (1, "bason", "bason hate pear", 99); """
sql """ INSERT INTO ${tableName} VALUES (2, "andy", "andy love apple", 100); """
sql """ INSERT INTO ${tableName} VALUES (2, "bason", "bason hate pear", 99); """
sql """ INSERT INTO ${tableName} VALUES (3, "andy", "andy love apple", 100); """
sql """ INSERT INTO ${tableName} VALUES (3, "bason", "bason hate pear", 99); """

qt_sql """ select * from ${tableName} order by id, name, hobbies, score """
qt_sql """ select * from ${tableName} where name match "andy" order by id, name, hobbies, score """
qt_sql """ select * from ${tableName} where hobbies match "pear" order by id, name, hobbies, score """
qt_sql """ select * from ${tableName} where score < 100 order by id, name, hobbies, score """
sql """ INSERT INTO ${table_name} VALUES (1, "andy", "andy love apple", 100); """
sql """ INSERT INTO ${table_name} VALUES (1, "bason", "bason hate pear", 99); """
sql """ INSERT INTO ${table_name} VALUES (2, "andy", "andy love apple", 100); """
sql """ INSERT INTO ${table_name} VALUES (2, "bason", "bason hate pear", 99); """
sql """ INSERT INTO ${table_name} VALUES (3, "andy", "andy love apple", 100); """
sql """ INSERT INTO ${table_name} VALUES (3, "bason", "bason hate pear", 99); """

qt_sql """ select * from ${table_name} order by id, name, hobbies, score """
qt_sql """ select * from ${table_name} where name match "andy" order by id, name, hobbies, score """
qt_sql """ select * from ${table_name} where hobbies match "pear" order by id, name, hobbies, score """
qt_sql """ select * from ${table_name} where score < 100 order by id, name, hobbies, score """

rowsetCount = get_rowset_count.call(tablets);
if (isCloudMode) {
Expand All @@ -228,7 +181,7 @@ suite("test_index_compaction_unique_keys_arr", "array_contains_inverted_index")
assert (rowsetCount == 7 * replicaNum)
}

// trigger full compactions for all tablets in ${tableName}
// trigger full compactions for all tablets in ${table_name}
trigger_full_compaction_on_tablets.call(tablets)

// wait for full compaction done
Expand All @@ -242,10 +195,86 @@ suite("test_index_compaction_unique_keys_arr", "array_contains_inverted_index")
assert (rowsetCount == 1 * replicaNum)
}

qt_sql """ select * from ${tableName} order by id, name, hobbies, score """
qt_sql """ select * from ${tableName} where name match "andy" order by id, name, hobbies, score """
qt_sql """ select * from ${tableName} where hobbies match "pear" order by id, name, hobbies, score """
qt_sql """ select * from ${tableName} where score < 100 order by id, name, hobbies, score """
qt_sql """ select * from ${table_name} order by id, name, hobbies, score """
qt_sql """ select * from ${table_name} where name match "andy" order by id, name, hobbies, score """
qt_sql """ select * from ${table_name} where hobbies match "pear" order by id, name, hobbies, score """
qt_sql """ select * from ${table_name} where score < 100 order by id, name, hobbies, score """
}

boolean invertedIndexCompactionEnable = false
boolean has_update_be_config = false
try {
String backend_id;
backend_id = backendId_to_backendIP.keySet()[0]
def (code, out, err) = show_be_config(backendId_to_backendIP.get(backend_id), backendId_to_backendHttpPort.get(backend_id))

logger.info("Show config: code=" + code + ", out=" + out + ", err=" + err)
assertEquals(code, 0)
def configList = parseJson(out.trim())
assert configList instanceof List

for (Object ele in (List) configList) {
assert ele instanceof List<String>
if (((List<String>) ele)[0] == "inverted_index_compaction_enable") {
invertedIndexCompactionEnable = Boolean.parseBoolean(((List<String>) ele)[2])
logger.info("inverted_index_compaction_enable: ${((List<String>) ele)[2]}")
}
if (((List<String>) ele)[0] == "disable_auto_compaction") {
disableAutoCompaction = Boolean.parseBoolean(((List<String>) ele)[2])
logger.info("disable_auto_compaction: ${((List<String>) ele)[2]}")
}
}
set_be_config.call("inverted_index_compaction_enable", "true")
has_update_be_config = true
// check updated config
check_config.call("inverted_index_compaction_enable", "true");

sql """ DROP TABLE IF EXISTS ${tableName}; """
sql """
CREATE TABLE ${tableName} (
`id` int(11) NULL,
`name` varchar(255) NULL,
`hobbies` text NULL,
`score` int(11) NULL,
index index_name (name) using inverted,
index index_hobbies (hobbies) using inverted properties("parser"="english"),
index index_score (score) using inverted
) ENGINE=OLAP
UNIQUE KEY(`id`)
COMMENT 'OLAP'
DISTRIBUTED BY HASH(`id`) BUCKETS 1
PROPERTIES (
"replication_num" = "1",
"disable_auto_compaction" = "true",
"enable_unique_key_merge_on_write" = "true"
);
"""

run_test.call(tableName)

tableName = "test_index_compaction_unique_keys_arr_cluster_key"
sql """ DROP TABLE IF EXISTS ${tableName}; """
sql """
CREATE TABLE ${tableName} (
`id` int(11) NULL,
`name` varchar(255) NULL,
`hobbies` text NULL,
`score` int(11) NULL,
index index_name (name) using inverted,
index index_hobbies (hobbies) using inverted properties("parser"="english"),
index index_score (score) using inverted
) ENGINE=OLAP
UNIQUE KEY(`id`)
CLUSTER BY (`score`)
COMMENT 'OLAP'
DISTRIBUTED BY HASH(`id`) BUCKETS 1
PROPERTIES (
"replication_num" = "1",
"disable_auto_compaction" = "true",
"enable_unique_key_merge_on_write" = "true"
);
"""
run_test.call(tableName)

} finally {
if (has_update_be_config) {
Expand Down
Loading