Skip to content

Commit d3833e4

Browse files
authored
[fix](test) Force meta sync to avoid stale meta data on follower fe when mv rewrite (#54296)
### What problem does this PR solve? Force meta sync to avoid stale meta data on follower fe when mv rewrite Such as the regression test code as fllowing, if the test code run on follower fe, `mv_rewrite_fail` method check would fail sometimes, because the meta data on follower fe is not consistant from master fe and the `SHOW ALTER TABLE MATERIALIZED VIEW` statement is always forwarded to master fe to run. create table table1( k1 int null, k2 int not null, k3 bigint null, k4 bigint null, k5 varchar(100) null ) duplicate key (k1, k2, k3) distributed by hash(k1) buckets 3 properties("replication_num" = "1"); insert into table1 select e1, -4, -4, -4, 'd' from (select 1 k1) as t lateral view explode_numbers(100) tmp1 as e1; create materialized view common_mv as select k1, k3, sum(k2), count(k4) from ${tblName} group by k1, k3; SHOW ALTER TABLE MATERIALIZED VIEW from table1 where TableName='common_mv' ORDER BY CreateTime DESC; -- if the mv status is finished by above show statement, then check the mv should rewrite fail, but sometimes the common_mv is not part in the -- mv rewrite which cause the test case fail. mv_rewrite_fail("""select count(k1) from agg_use_key_direct""", "common_mv")
1 parent 40b9423 commit d3833e4

File tree

1 file changed

+31
-0
lines changed
  • regression-test/framework/src/main/groovy/org/apache/doris/regression/suite

1 file changed

+31
-0
lines changed

regression-test/framework/src/main/groovy/org/apache/doris/regression/suite/Suite.groovy

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2133,6 +2133,7 @@ class Suite implements GroovyInterceptable {
21332133
AS ${mv_sql}
21342134
"""
21352135
waitingMVTaskFinishedByMvName(db, table_name, mv_name)
2136+
sql """sync;"""
21362137
}
21372138

21382139
def create_async_mv = { db, mv_name, mv_sql ->
@@ -2148,6 +2149,8 @@ class Suite implements GroovyInterceptable {
21482149
def job_name = getJobName(db, mv_name);
21492150
waitingMTMVTaskFinished(job_name)
21502151
sql "analyze table ${db}.${mv_name} with sync;"
2152+
// force meta sync to avoid stale meta data on follower fe
2153+
sql """sync;"""
21512154
}
21522155

21532156
def create_async_partition_mv = { db, mv_name, mv_sql, partition_col ->
@@ -2164,6 +2167,8 @@ class Suite implements GroovyInterceptable {
21642167
def job_name = getJobName(db, mv_name);
21652168
waitingMTMVTaskFinished(job_name)
21662169
sql "analyze table ${db}.${mv_name} with sync;"
2170+
// force meta sync to avoid stale meta data on follower fe
2171+
sql """sync;"""
21672172
}
21682173

21692174
// mv not part in rewrite process
@@ -2207,6 +2212,8 @@ class Suite implements GroovyInterceptable {
22072212
void mv_rewrite_success(query_sql, mv_name, is_partition_statistics_ready = true) {
22082213
logger.info("query_sql = " + query_sql + ", mv_name = " + mv_name
22092214
+ ", is_partition_statistics_ready = " + is_partition_statistics_ready)
2215+
// force meta sync to avoid stale meta data on follower fe
2216+
sql """sync;"""
22102217
if (!is_partition_statistics_ready) {
22112218
// If partition statistics is no ready, degrade to without check cbo chosen
22122219
mv_rewrite_success_without_check_chosen(query_sql, mv_name)
@@ -2224,6 +2231,8 @@ class Suite implements GroovyInterceptable {
22242231
void mv_rewrite_all_success( query_sql, mv_names, is_partition_statistics_ready = true) {
22252232
logger.info("query_sql = " + query_sql + ", mv_names = " + mv_names
22262233
+ ", is_partition_statistics_ready = " + is_partition_statistics_ready)
2234+
// force meta sync to avoid stale meta data on follower fe
2235+
sql """sync;"""
22272236
if (!is_partition_statistics_ready) {
22282237
// If partition statistics is no ready, degrade to without check cbo chosen
22292238
mv_rewrite_all_success_without_check_chosen(query_sql, mv_names)
@@ -2250,6 +2259,8 @@ class Suite implements GroovyInterceptable {
22502259
void mv_rewrite_any_success(query_sql, mv_names, is_partition_statistics_ready = true) {
22512260
logger.info("query_sql = " + query_sql + ", mv_names = " + mv_names
22522261
+ ", is_partition_statistics_ready = " + is_partition_statistics_ready)
2262+
// force meta sync to avoid stale meta data on follower fe
2263+
sql """sync;"""
22532264
if (!is_partition_statistics_ready) {
22542265
// If partition statistics is no ready, degrade to without check cbo chosen
22552266
mv_rewrite_any_success_without_check_chosen(query_sql, mv_names)
@@ -2273,6 +2284,8 @@ class Suite implements GroovyInterceptable {
22732284
// multi mv part in rewrite process, all rewrte success without check if chosen by cbo
22742285
void mv_rewrite_all_success_without_check_chosen(query_sql, mv_names) {
22752286
logger.info("query_sql = " + query_sql + ", mv_names = " + mv_names)
2287+
// force meta sync to avoid stale meta data on follower fe
2288+
sql """sync;"""
22762289
explain {
22772290
sql(" memo plan ${query_sql}")
22782291
check {result ->
@@ -2292,6 +2305,8 @@ class Suite implements GroovyInterceptable {
22922305
// multi mv part in rewrite process, any of them rewrte success without check if chosen by cbo or not
22932306
void mv_rewrite_any_success_without_check_chosen(query_sql, mv_names) {
22942307
logger.info("query_sql = " + query_sql + ", mv_names = " + mv_names)
2308+
// force meta sync to avoid stale meta data on follower fe
2309+
sql """sync;"""
22952310
explain {
22962311
sql(" memo plan ${query_sql}")
22972312
check { result ->
@@ -2310,6 +2325,8 @@ class Suite implements GroovyInterceptable {
23102325
// multi mv part in rewrite process, rewrte success without check if chosen by cbo or not
23112326
void mv_rewrite_success_without_check_chosen(query_sql, mv_name) {
23122327
logger.info("query_sql = " + query_sql + ", mv_name = " + mv_name)
2328+
// force meta sync to avoid stale meta data on follower fe
2329+
sql """sync;"""
23132330
explain {
23142331
sql(" memo plan ${query_sql}")
23152332
check { result ->
@@ -2321,6 +2338,8 @@ class Suite implements GroovyInterceptable {
23212338
// single mv part in rewrite process, rewrte fail
23222339
void mv_rewrite_fail(query_sql, mv_name) {
23232340
logger.info("query_sql = " + query_sql + ", mv_name = " + mv_name)
2341+
// force meta sync to avoid stale meta data on follower fe
2342+
sql """sync;"""
23242343
explain {
23252344
sql(" memo plan ${query_sql}")
23262345
contains(".${mv_name} fail")
@@ -2330,6 +2349,8 @@ class Suite implements GroovyInterceptable {
23302349
// multi mv part in rewrite process, all rewrte fail
23312350
void mv_rewrite_all_fail(query_sql, mv_names) {
23322351
logger.info("query_sql = " + query_sql + ", mv_names = " + mv_names)
2352+
// force meta sync to avoid stale meta data on follower fe
2353+
sql """sync;"""
23332354
explain {
23342355
sql(" memo plan ${query_sql}")
23352356
check {result ->
@@ -2349,6 +2370,8 @@ class Suite implements GroovyInterceptable {
23492370
// multi mv part in rewrite process, any rewrte fail
23502371
void mv_rewrite_any_fail (query_sql, mv_names) {
23512372
logger.info("query_sql = " + query_sql + ", mv_names = " + mv_names)
2373+
// force meta sync to avoid stale meta data on follower fe
2374+
sql """sync;"""
23522375
explain {
23532376
sql(" memo plan ${query_sql}")
23542377
check { result ->
@@ -2376,6 +2399,8 @@ class Suite implements GroovyInterceptable {
23762399
"""
23772400
def job_name = getJobName(db, mv_name);
23782401
waitingMTMVTaskFinished(job_name)
2402+
// force meta sync to avoid stale meta data on follower fe
2403+
sql """sync;"""
23792404
mv_rewrite_success(query_sql, mv_name)
23802405
}
23812406

@@ -2392,6 +2417,8 @@ class Suite implements GroovyInterceptable {
23922417

23932418
def job_name = getJobName(db, mv_name);
23942419
waitingMTMVTaskFinished(job_name)
2420+
// force meta sync to avoid stale meta data on follower fe
2421+
sql """sync;"""
23952422
mv_rewrite_success_without_check_chosen(query_sql, mv_name)
23962423
}
23972424

@@ -2409,6 +2436,8 @@ class Suite implements GroovyInterceptable {
24092436

24102437
def job_name = getJobName(db, mv_name);
24112438
waitingMTMVTaskFinished(job_name)
2439+
// force meta sync to avoid stale meta data on follower fe
2440+
sql """sync;"""
24122441
mv_rewrite_fail(query_sql, mv_name)
24132442
}
24142443

@@ -2424,6 +2453,8 @@ class Suite implements GroovyInterceptable {
24242453

24252454
def job_name = getJobName(db, mv_name);
24262455
waitingMTMVTaskFinished(job_name)
2456+
// force meta sync to avoid stale meta data on follower fe
2457+
sql """sync;"""
24272458
}
24282459

24292460
def token = context.config.metaServiceToken

0 commit comments

Comments
 (0)