From b66744c5eb722b07ae6553502af1c58b19163222 Mon Sep 17 00:00:00 2001 From: shuke <37901441+shuke987@users.noreply.github.com> Date: Wed, 8 Jul 2026 19:37:41 +0800 Subject: [PATCH 1/2] [fix](regression) Deflake segcompaction agg keys case --- .../test_segcompaction_agg_keys.groovy | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/regression-test/suites/segcompaction_p2/test_segcompaction_agg_keys.groovy b/regression-test/suites/segcompaction_p2/test_segcompaction_agg_keys.groovy index d16627f956f1ff..312031b6857bdf 100644 --- a/regression-test/suites/segcompaction_p2/test_segcompaction_agg_keys.groovy +++ b/regression-test/suites/segcompaction_p2/test_segcompaction_agg_keys.groovy @@ -89,14 +89,21 @@ suite("test_segcompaction_agg_keys") { // Cannot use qt_select_default here: S3 Load parallelizes across multiple BE workers, // each creating separate segments with non-deterministic sequence numbers. // REPLACE aggregation picks the value from the segment with the highest sequence, - // so the winner among the 12 source rows with col_0=47 is not guaranteed across runs. - def selectResult = sql """ SELECT * FROM ${tableName} WHERE col_0=47; """ - assertEquals(1, selectResult.size(), "Expected exactly 1 row for col_0=47 after REPLACE aggregation") - def row = selectResult[0].collect { it?.toString() } - def possibleResult1 = ["47", "Lychee", "Lychee", "Plum", "Banana", "Lychee", "Lychee", "Cherry", "Pineapple", "Banana", "Watermelon", "Mango", "Apple", "Apple", "Peach", "Raspberry", "Grapes", "Raspberry", "Raspberry", "Kiwi", "Orange", "Apple", "Plum", "Blueberry", "Strawberry", "Orange", "Raspberry", "Strawberry", "Lemon", "Orange", "Blueberry", "Apple", "Peach", "Banana", "Kiwi", "Orange", "Banana", "Strawberry", "Lemon", "Mango", "Orange", "Peach", "Avocado", "Pineapple", "Kiwi", "Lemon", "Grapes", "Strawberry", "Grapes", "Lychee"] - def possibleResult2 = ["47", "Banana", "Watermelon", "Lychee", "Blueberry", "Raspberry", "Strawberry", "Grapes", "Watermelon", "Lemon", "Lemon", "Pineapple", "Watermelon", "Peach", "Kiwi", "Lychee", "Peach", "Pineapple", "Raspberry", "Grapes", "Lychee", "Raspberry", "Peach", "Kiwi", "Pineapple", "Apple", "Lemon", "Lychee", "Pineapple", "Blueberry", "Blueberry", "Avocado", "Cherry", "Kiwi", "Cherry", "Watermelon", "Plum", "Banana", "Peach", "Pineapple", "Apple", "Strawberry", "Avocado", "Kiwi", "Blueberry", "Mango", "Watermelon", "Orange", "Strawberry", "Banana"] - assertTrue(row == possibleResult1 || row == possibleResult2, - "Result for col_0=47 does not match either expected outcome.\nGot: ${row}") + // so validate stable invariants instead of pinning a specific duplicate-key winner. + def result = sql """ SELECT * FROM ${tableName} WHERE col_0=47; """ + assertEquals(1, result.size(), "Expected exactly 1 row for col_0=47 after REPLACE aggregation") + assertEquals(50, result[0].size()) + assertEquals("47", result[0][0].toString()) + + def validValues = [ + "Apple", "Avocado", "Banana", "Blueberry", "Cherry", "Grapes", + "Kiwi", "Lemon", "Lychee", "Mango", "Orange", "Peach", + "Pineapple", "Plum", "Raspberry", "Strawberry", "Watermelon" + ] as Set + for (int i = 1; i < result[0].size(); i++) { + assertTrue(validValues.contains(result[0][i]), + "unexpected value for col_${i}: ${result[0][i]}") + } String[][] tablets = sql """ show tablets from ${tableName}; """ From 08a4c4b16eeec108f8d85118f6faf45da24fee80 Mon Sep 17 00:00:00 2001 From: shuke <37901441+shuke987@users.noreply.github.com> Date: Thu, 9 Jul 2026 17:55:38 +0800 Subject: [PATCH 2/2] [fix](regression) Preserve segcompaction source row coverage --- .../test_segcompaction_agg_keys.groovy | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/regression-test/suites/segcompaction_p2/test_segcompaction_agg_keys.groovy b/regression-test/suites/segcompaction_p2/test_segcompaction_agg_keys.groovy index 312031b6857bdf..4b838f1af50299 100644 --- a/regression-test/suites/segcompaction_p2/test_segcompaction_agg_keys.groovy +++ b/regression-test/suites/segcompaction_p2/test_segcompaction_agg_keys.groovy @@ -89,21 +89,20 @@ suite("test_segcompaction_agg_keys") { // Cannot use qt_select_default here: S3 Load parallelizes across multiple BE workers, // each creating separate segments with non-deterministic sequence numbers. // REPLACE aggregation picks the value from the segment with the highest sequence, - // so validate stable invariants instead of pinning a specific duplicate-key winner. + // so accept any complete source row instead of pinning one deterministic winner. def result = sql """ SELECT * FROM ${tableName} WHERE col_0=47; """ assertEquals(1, result.size(), "Expected exactly 1 row for col_0=47 after REPLACE aggregation") assertEquals(50, result[0].size()) assertEquals("47", result[0][0].toString()) - def validValues = [ - "Apple", "Avocado", "Banana", "Blueberry", "Cherry", "Grapes", - "Kiwi", "Lemon", "Lychee", "Mango", "Orange", "Peach", - "Pineapple", "Plum", "Raspberry", "Strawberry", "Watermelon" - ] as Set - for (int i = 1; i < result[0].size(); i++) { - assertTrue(validValues.contains(result[0][i]), - "unexpected value for col_${i}: ${result[0][i]}") - } + def sourceRows = new File(context.dataPath, "test_segcompaction_dup_keys.out") + .readLines() + .findAll { it.startsWith("47\t") } + .collect { it.split("\t", -1).toList() } + assertEquals(12, sourceRows.size(), "Unexpected col_0=47 source row count") + def row = result[0].collect { it?.toString() } + assertTrue(sourceRows.contains(row), + "Result for col_0=47 is not one complete source row: ${row}") String[][] tablets = sql """ show tablets from ${tableName}; """