diff --git a/regression-test/suites/inverted_index_p0/index_change/test_index_change_with_cumulative_compaction.groovy b/regression-test/suites/inverted_index_p0/index_change/test_index_change_with_cumulative_compaction.groovy index 2693047a34b90a..340a5c40d5119a 100644 --- a/regression-test/suites/inverted_index_p0/index_change/test_index_change_with_cumulative_compaction.groovy +++ b/regression-test/suites/inverted_index_p0/index_change/test_index_change_with_cumulative_compaction.groovy @@ -40,6 +40,23 @@ suite("test_index_change_with_cumulative_compaction") { assertTrue(useTime <= OpTimeout, "wait_for_latest_op_on_table_finish timeout") } + def trigger_compaction_with_retry = {table_name, compaction_type = "cumulative", max_retries = 10, delay_ms = 2000 -> + def retry_count = 0 + while (true) { + try { + trigger_and_wait_compaction(table_name, compaction_type) + return // Success + } catch (Exception e) { + retry_count++ + if (retry_count >= max_retries) { + throw new Exception("Failed to complete ${compaction_type} compaction after ${max_retries} attempts", e) + } + logger.warn("Compaction attempt ${retry_count} failed: ${e.getMessage()}") + Thread.sleep(delay_ms) + } + } + } + try { //BackendId,Cluster,IP,HeartbeatPort,BePort,HttpPort,BrpcPort,LastStartTime,LastHeartbeat,Alive,SystemDecommissioned,ClusterDecommissioned,TabletNum,DataUsedCapacity,AvailCapacity,TotalCapacity,UsedPct,MaxDiskUsedPct,Tag,ErrMsg,Version,Status String[][] backends = sql """ show backends; """ @@ -148,7 +165,7 @@ suite("test_index_change_with_cumulative_compaction") { sql "build index idx_city on ${tableName}" // trigger compactions for all tablets in ${tableName} - trigger_and_wait_compaction(tableName, "cumulative") + trigger_compaction_with_retry(tableName, "cumulative") int rowCount = 0 for (def tablet in tablets) {