This is an automated email from the ASF dual-hosted git repository. yiguolei pushed a commit to branch branch-2.1 in repository https://gitbox.apache.org/repos/asf/doris.git
commit e9f9fdf9afce075e73f70c962309f679d67ba048 Author: Jibing-Li <[email protected]> AuthorDate: Mon Feb 5 21:12:54 2024 +0800 Fix unstable analyze mv case. (#30859) --- .../suites/statistics/test_analyze_mv.groovy | 33 ++++++++++++++++------ .../suites/statistics/test_select_mv.groovy | 19 ++++++++++++- 2 files changed, 43 insertions(+), 9 deletions(-) diff --git a/regression-test/suites/statistics/test_analyze_mv.groovy b/regression-test/suites/statistics/test_analyze_mv.groovy index 91c4c24f70d..769979df3d8 100644 --- a/regression-test/suites/statistics/test_analyze_mv.groovy +++ b/regression-test/suites/statistics/test_analyze_mv.groovy @@ -17,6 +17,23 @@ suite("test_analyze_mv") { + def wait_mv_finish = { db -> + while(true) { + Thread.sleep(1000) + boolean finished = true; + def result = sql """SHOW ALTER TABLE MATERIALIZED VIEW FROM ${db};""" + for (int i = 0; i < result.size(); i++) { + if (result[i][8] != 'FINISHED') { + finished = false; + break; + } + } + if (finished) { + break; + } + } + } + sql """drop database if exists test_analyze_mv""" sql """create database test_analyze_mv""" sql """use test_analyze_mv""" @@ -36,11 +53,11 @@ suite("test_analyze_mv") { ) """ sql """create materialized view mv1 as select key1 from mvTestDup;""" - Thread.sleep(1500) + wait_mv_finish("test_analyze_mv") sql """create materialized view mv2 as select key2 from mvTestDup;""" - Thread.sleep(1500) + wait_mv_finish("test_analyze_mv") sql """create materialized view mv3 as select key1, key2, sum(value1), max(value2), min(value3) from mvTestDup group by key1, key2;""" - Thread.sleep(1500) + wait_mv_finish("test_analyze_mv") sql """insert into mvTestDup values (1, 2, 3, 4, 5), (1, 2, 3, 4, 5), (10, 20, 30, 40, 50), (10, 20, 30, 40, 50), (100, 200, 300, 400, 500), (1001, 2001, 3001, 4001, 5001);""" sql """analyze table mvTestDup with sync;""" @@ -130,11 +147,11 @@ suite("test_analyze_mv") { """ sql """create materialized view mv1 as select key2 from mvTestAgg;""" - Thread.sleep(1500) + wait_mv_finish("test_analyze_mv") sql """create materialized view mv3 as select key1, key2, sum(value1), max(value2), min(value3) from mvTestAgg group by key1, key2;""" - Thread.sleep(1500) + wait_mv_finish("test_analyze_mv") sql """create materialized view mv6 as select key1, sum(value1) from mvTestAgg group by key1;""" - Thread.sleep(1500) + wait_mv_finish("test_analyze_mv") sql """insert into mvTestAgg values (1, 2, 3, 4, 5), (1, 2, 3, 4, 5), (1, 11, 22, 33, 44), (10, 20, 30, 40, 50), (10, 20, 30, 40, 50), (100, 200, 300, 400, 500), (1001, 2001, 3001, 4001, 5001);""" sql """analyze table mvTestAgg with sync;""" @@ -210,9 +227,9 @@ suite("test_analyze_mv") { """ sql """create materialized view mv1 as select key1 from mvTestUni;""" - Thread.sleep(1000) + wait_mv_finish("test_analyze_mv") sql """create materialized view mv6 as select key2, value2, value3 from mvTestUni;""" - Thread.sleep(1000) + wait_mv_finish("test_analyze_mv") sql """insert into mvTestUni values (1, 2, 3, 4, 5), (1, 2, 3, 7, 8), (1, 11, 22, 33, 44), (10, 20, 30, 40, 50), (10, 20, 30, 40, 50), (100, 200, 300, 400, 500), (1001, 2001, 3001, 4001, 5001);""" sql """analyze table mvTestUni with sync;""" diff --git a/regression-test/suites/statistics/test_select_mv.groovy b/regression-test/suites/statistics/test_select_mv.groovy index 5378abb598c..8c3417cb4b9 100644 --- a/regression-test/suites/statistics/test_select_mv.groovy +++ b/regression-test/suites/statistics/test_select_mv.groovy @@ -17,6 +17,23 @@ suite("test_select_mv") { + def wait_mv_finish = { db -> + while(true) { + Thread.sleep(1000) + boolean finished = true; + def result = sql """SHOW ALTER TABLE MATERIALIZED VIEW FROM ${db};""" + for (int i = 0; i < result.size(); i++) { + if (result[i][8] != 'FINISHED') { + finished = false; + break; + } + } + if (finished) { + break; + } + } + } + def dup_sql1 = """select count(*) from test_dup;""" def dup_sql2 = """select mv_key2 from test_dup index dup1 order by mv_key2;""" def dup_sql3 = """select count(mv_key2) from test_dup index dup1;""" @@ -69,7 +86,7 @@ suite("test_select_mv") { sql """ create materialized view agg1 as select key2, sum(value) from test_agg group by key2; """ - Thread.sleep(1000) + wait_mv_finish("test_select_mv") sql """insert into test_dup values (1, 1, 1), (2, 2, 2)""" sql """insert into test_dup values (1, 1, 1), (2, 2, 2)""" --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
