From b69f53aabf86fb94437501ca7e38fb620a7a5445 Mon Sep 17 00:00:00 2001 From: yujun Date: Wed, 27 May 2026 20:21:49 +0800 Subject: [PATCH] [fix](regression) Wait row count before hot value analyze ### What problem does this PR solve? Issue Number: None Related PR: None Problem Summary: The hot value analyze regression test can run sample analyze before Cloud table row count metadata is reported. In that state sample analyze treats the table as empty and writes empty column statistics, making the test flaky. Wait for SHOW DATA to report the inserted row count before running analyze on non-empty test tables. ### Release note None ### Check List (For Author) - Test: Regression test - ./build.sh --fe - ./run-regression-test.sh --run -d statistics -s test_full_analyze_hot_value - git diff --check - Behavior changed: No - Does this need documentation: No --- .../test_full_analyze_hot_value.groovy | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/regression-test/suites/statistics/test_full_analyze_hot_value.groovy b/regression-test/suites/statistics/test_full_analyze_hot_value.groovy index f2e5031eb19a89..ad7df099e8dd15 100644 --- a/regression-test/suites/statistics/test_full_analyze_hot_value.groovy +++ b/regression-test/suites/statistics/test_full_analyze_hot_value.groovy @@ -16,6 +16,35 @@ // under the License. suite("test_full_analyze_hot_value") { + def wait_row_count_reported = { db, table, row, column, expected -> + def result = sql """show frontends;""" + logger.info("show frontends result origin: " + result) + def host + def port + for (int i = 0; i < result.size(); i++) { + if (result[i][8] == "true") { + host = result[i][1] + port = result[i][4] + } + } + def tokens = context.config.jdbcUrl.split('/') + def url = tokens[0] + "//" + host + ":" + port + logger.info("Master url is " + url) + connect(context.config.jdbcUser, context.config.jdbcPassword, url) { + sql """use ${db}""" + result = sql """show frontends;""" + logger.info("show frontends result master: " + result) + for (int i = 0; i < 120; i++) { + Thread.sleep(5000) + result = sql """SHOW DATA FROM ${table};""" + logger.info("result " + result) + if (result[row][column] == expected) { + return; + } + } + throw new Exception("Row count report timeout.") + } + } sql """drop database if exists test_full_analyze_hot_value""" sql """create database test_full_analyze_hot_value""" @@ -37,6 +66,7 @@ suite("test_full_analyze_hot_value") { """ // Insert 100 rows: value1 has 2 values, "0" and "1", each appearing 50 times sql """insert into full_hot_skew select number, number % 2 from numbers("number"="100")""" + wait_row_count_reported("test_full_analyze_hot_value", "full_hot_skew", 0, 4, "100") sql """analyze table full_hot_skew with sync""" def result = sql """show column stats full_hot_skew(value1)""" @@ -94,6 +124,7 @@ suite("test_full_analyze_hot_value") { ) """ sql """insert into full_hot_special select number, " : ;a" from numbers("number"="100")""" + wait_row_count_reported("test_full_analyze_hot_value", "full_hot_special", 0, 4, "100") sql """analyze table full_hot_special with sync with hot value""" result = sql """show column stats full_hot_special(value1)""" @@ -173,6 +204,7 @@ suite("test_full_analyze_hot_value") { ) """ sql """insert into full_hot_all_null select number, null from numbers("number"="100")""" + wait_row_count_reported("test_full_analyze_hot_value", "full_hot_all_null", 0, 4, "100") sql """analyze table full_hot_all_null with sync with hot value""" result = sql """show column stats full_hot_all_null(value1)""" logger.info("Test9 all-null result: " + result)