This is an automated email from the ASF dual-hosted git repository.

yiguolei pushed a commit to branch branch-4.1
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-4.1 by this push:
     new e7139e850c7 branch-4.1: [fix](regression) Wait for stable colocate 
groups in plan tests #64361 (#64981)
e7139e850c7 is described below

commit e7139e850c7ed890297d6da6c052d211294a49e3
Author: morrySnow <[email protected]>
AuthorDate: Tue Jun 30 16:09:57 2026 +0800

    branch-4.1: [fix](regression) Wait for stable colocate groups in plan tests 
#64361 (#64981)
    
    Backport PR: #64361
---
 .../org/apache/doris/regression/suite/Suite.groovy | 15 +++++++++
 .../test_backup_restore_colocate.groovy            | 38 +++-------------------
 .../test_colocate_join_of_column_order.groovy      |  2 ++
 .../join/colocate_join_with_rollup.groovy          |  1 +
 4 files changed, 23 insertions(+), 33 deletions(-)

diff --git 
a/regression-test/framework/src/main/groovy/org/apache/doris/regression/suite/Suite.groovy
 
b/regression-test/framework/src/main/groovy/org/apache/doris/regression/suite/Suite.groovy
index 46966604815..192f1c2fb7f 100644
--- 
a/regression-test/framework/src/main/groovy/org/apache/doris/regression/suite/Suite.groovy
+++ 
b/regression-test/framework/src/main/groovy/org/apache/doris/regression/suite/Suite.groovy
@@ -982,6 +982,21 @@ class Suite implements GroovyInterceptable {
         throw new RuntimeException("dictionary ${dictName} are not ready, 
status: ${result}")
     }
 
+    void waitForColocateGroupStable(String groupName, int timeoutSeconds = 60) 
{
+        waitForColocateGroupStable(context.dbName, groupName, timeoutSeconds)
+    }
+
+    void waitForColocateGroupStable(String dbName, String groupName, int 
timeoutSeconds = 60) {
+        String fullGroupName = "${dbName}.${groupName}"
+        logger.info("wait colocate group ${fullGroupName} stable")
+        awaitUntil(timeoutSeconds) {
+            def groups = sql_return_maparray("SHOW PROC '/colocation_group'")
+            def group = groups.find { it.GroupName == fullGroupName }
+            return group != null && group.IsStable == "true"
+        }
+        logger.info("colocate group ${fullGroupName} is stable")
+    }
+
     void flightRecord(Closure actionSupplier) {
         runAction(new FlightRecordAction(context), actionSupplier)
     }
diff --git 
a/regression-test/suites/backup_restore/test_backup_restore_colocate.groovy 
b/regression-test/suites/backup_restore/test_backup_restore_colocate.groovy
index 20588be01e9..e8a61f776b1 100644
--- a/regression-test/suites/backup_restore/test_backup_restore_colocate.groovy
+++ b/regression-test/suites/backup_restore/test_backup_restore_colocate.groovy
@@ -51,19 +51,6 @@ suite("test_backup_restore_colocate", 
"backup_restore,external") {
         assertTrue(result.ColocateMismatchNum as int == 0)
     }
 
-    // The planner only produces a COLOCATE join once the colocate group is 
stable.
-    // Right after a restore the restored group may still be stabilizing, so 
poll the
-    // explain plan until COLOCATE shows up (bounded wait) before asserting on 
it.
-    def waitColocatePlan = { q ->
-        def plan = q.replaceAll(/;\s*$/, "")
-        for (int i = 0; i < 60; i++) {
-            if (sql("explain ${plan}").toString().contains("COLOCATE")) {
-                break
-            }
-            sleep(1000)
-        }
-    }
-
     def syncer = getSyncer()
     syncer.createS3Repository(repoName)
 
@@ -118,7 +105,7 @@ suite("test_backup_restore_colocate", 
"backup_restore,external") {
     res = sql "SELECT * FROM ${dbName}.${tableName2}"
     assertEquals(res.size(), insert_num)
 
-    waitColocatePlan(query)
+    waitForColocateGroupStable(dbName, groupName)
     explain {
         sql("${query}")
         contains("COLOCATE")
@@ -224,8 +211,7 @@ suite("test_backup_restore_colocate", 
"backup_restore,external") {
     res = sql "SELECT * FROM ${dbName}.${tableName2}"
     assertEquals(res.size(), insert_num)
 
-
-    waitColocatePlan(query)
+    waitForColocateGroupStable(dbName, groupName)
     explain {
         sql("${query}")
         contains("COLOCATE")
@@ -411,19 +397,6 @@ suite("test_backup_restore_colocate_with_partition", 
"backup_restore") {
         assertTrue(result.ColocateMismatchNum as int == 0)
     }
 
-    // The planner only produces a COLOCATE join once the colocate group is 
stable.
-    // Right after a restore the restored group may still be stabilizing, so 
poll the
-    // explain plan until COLOCATE shows up (bounded wait) before asserting on 
it.
-    def waitColocatePlan = { q ->
-        def plan = q.replaceAll(/;\s*$/, "")
-        for (int i = 0; i < 60; i++) {
-            if (sql("explain ${plan}").toString().contains("COLOCATE")) {
-                break
-            }
-            sleep(1000)
-        }
-    }
-
     def syncer = getSyncer()
     syncer.createS3Repository(repoName)
 
@@ -494,7 +467,7 @@ suite("test_backup_restore_colocate_with_partition", 
"backup_restore") {
     res = sql "SELECT * FROM ${dbName}.${tableName2}"
     assertEquals(res.size(), insert_num)
 
-    waitColocatePlan(query)
+    waitForColocateGroupStable(dbName, groupName)
     explain {
         sql("${query}")
         contains("COLOCATE")
@@ -598,8 +571,7 @@ suite("test_backup_restore_colocate_with_partition", 
"backup_restore") {
     res = sql "SELECT * FROM ${dbName}.${tableName2}"
     assertEquals(res.size(), insert_num)
 
-
-    waitColocatePlan(query)
+    waitForColocateGroupStable(dbName, groupName)
     explain {
         sql("${query}")
         contains("COLOCATE")
@@ -674,7 +646,7 @@ suite("test_backup_restore_colocate_with_partition", 
"backup_restore") {
 
     query = "select * from ${newDbName}.${tableName1} as t1, 
${newDbName}.${tableName2} as t2 where t1.id=t2.id;"
 
-    waitColocatePlan(query)
+    waitForColocateGroupStable(newDbName, groupName)
     explain {
         sql("${query}")
         contains("COLOCATE")
diff --git 
a/regression-test/suites/correctness_p0/test_colocate_join_of_column_order.groovy
 
b/regression-test/suites/correctness_p0/test_colocate_join_of_column_order.groovy
index d6d27e03f76..c62ba0aff88 100644
--- 
a/regression-test/suites/correctness_p0/test_colocate_join_of_column_order.groovy
+++ 
b/regression-test/suites/correctness_p0/test_colocate_join_of_column_order.groovy
@@ -68,6 +68,7 @@ suite("test_colocate_join_of_column_order") {
         sql("select * from test_colocate_join_of_column_order_t1 a join 
test_colocate_join_of_column_order_t2 b on a.k1=b.k2 and a.v=b.v;")
         notContains "COLOCATE"
     }
+    waitForColocateGroupStable("group_column_order")
     explain {
         sql("select * from test_colocate_join_of_column_order_t1 a join 
test_colocate_join_of_column_order_t2 b on a.k1=b.k2 and a.k2=b.k1;")
         contains "COLOCATE"
@@ -112,6 +113,7 @@ suite("test_colocate_join_of_column_order") {
     sql """alter table test_colocate_join_of_column_order_tc modify column c1 
set stats ('row_count'='1', 'ndv'='1', 'num_nulls'='0', 'min_value'='1', 
'max_value'='1')"""
     sql """alter table test_colocate_join_of_column_order_tc modify column c2 
set stats ('row_count'='1', 'ndv'='1', 'num_nulls'='0', 'min_value'='1', 
'max_value'='1')"""
 
+    waitForColocateGroupStable("group_column_order3")
     explain {
         sql("""select /*+ set_var(disable_join_reorder=true) */ * from 
test_colocate_join_of_column_order_ta join [shuffle] (select cast((c2 + 1) as 
bigint) c2 from test_colocate_join_of_column_order_tb) 
test_colocate_join_of_column_order_tb  on 
test_colocate_join_of_column_order_ta.c1 = 
test_colocate_join_of_column_order_tb.c2 join [shuffle] 
test_colocate_join_of_column_order_tc on 
test_colocate_join_of_column_order_tb.c2 = 
test_colocate_join_of_column_order_tc.c1;""");
         contains "COLOCATE"
diff --git 
a/regression-test/suites/nereids_p0/join/colocate_join_with_rollup.groovy 
b/regression-test/suites/nereids_p0/join/colocate_join_with_rollup.groovy
index 235b86b013b..f6e2f486936 100644
--- a/regression-test/suites/nereids_p0/join/colocate_join_with_rollup.groovy
+++ b/regression-test/suites/nereids_p0/join/colocate_join_with_rollup.groovy
@@ -122,6 +122,7 @@ suite("colocate_join_with_rollup", "nereids_p0") {
             (20220107, 102, 202, 200, 100),
             (20220108, 101, 202, 200, 100);"""
 
+    waitForColocateGroupStable("group1")
     explain {
         sql("""select sum_col1,sum_col2 
             from 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to