Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix](regression)Fix unstable compaction related cases #46920

Merged
merged 3 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions regression-test/plugins/plugin_compaction.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ Suite.metaClass.be_run_full_compaction_by_table_id = { String ip, String port, S
}

logger.info("Added 'be_run_full_compaction' function to Suite")

Suite.metaClass.trigger_and_wait_compaction = { String table_name, String compaction_type, int timeout_seconds=300 ->
Suite.metaClass.trigger_and_wait_compaction = { String table_name, String compaction_type, int timeout_seconds=300, String[] ignored_errors=[] ->
if (!(compaction_type in ["cumulative", "base", "full"])) {
throw new IllegalArgumentException("invalid compaction type: ${compaction_type}, supported types: cumulative, base, full")
}
Expand Down Expand Up @@ -102,14 +101,16 @@ Suite.metaClass.trigger_and_wait_compaction = { String table_name, String compac
assert exit_code == 0: "trigger compaction failed, exit code: ${exit_code}, stdout: ${stdout}, stderr: ${stderr}"
def trigger_status = parseJson(stdout.trim())
if (trigger_status.status.toLowerCase() != "success") {
if (trigger_status.status.toLowerCase() == "already_exist") {
def status_lower = trigger_status.status.toLowerCase()
if (status_lower == "already_exist") {
triggered_tablets.add(tablet) // compaction already in queue, treat it as successfully triggered
} else if (!auto_compaction_disabled) {
// ignore the error if auto compaction enabled
} else if (trigger_status.status.contains("E-2000")) {
} else if (status_lower.contains("e-2000")) {
// ignore this tablet compaction.
}
else {
} else if (ignored_errors.any { error -> status_lower.contains(error.toLowerCase()) }) {
// ignore this tablet compaction if the error is in the ignored_errors list
} else {
throw new Exception("trigger compaction failed, be host: ${be_host}, tablet id: ${tablet.TabletId}, status: ${trigger_status.status}")
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,13 @@ suite("test_skip_index_compaction_fault_injection", "nonConcurrent") {
assert (rowsetCount == 11 * replicaNum)

// first
trigger_and_wait_compaction(tableName, "full")
trigger_and_wait_compaction(tableName, "full", 300, new String[]{"e-6010"})

rowsetCount = get_rowset_count.call(tablets);
assert (rowsetCount == 11 * replicaNum)

// second
trigger_and_wait_compaction(tableName, "full")
trigger_and_wait_compaction(tableName, "full", 300, new String[]{"e-6010"})

rowsetCount = get_rowset_count.call(tablets);
if (isCloudMode) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,25 @@ suite("test_index_change_with_cumulative_compaction", "nonConcurrent") {
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)
def wait_for_build_index_on_partition_finish = { table_name, OpTimeout ->
for(int t = delta_time; t <= OpTimeout; t += delta_time){
alter_res = sql """SHOW BUILD INDEX WHERE TableName = "${table_name}";"""
def expected_finished_num = alter_res.size();
def finished_num = 0;
for (int i = 0; i < expected_finished_num; i++) {
logger.info(table_name + " build index job state: " + alter_res[i][7] + i)
if (alter_res[i][7] == "FINISHED") {
++finished_num;
}
logger.warn("Compaction attempt ${retry_count} failed: ${e.getMessage()}")
Thread.sleep(delay_ms)
}
if (finished_num == expected_finished_num) {
logger.info(table_name + " all build index jobs finished, detail: " + alter_res)
break
}
useTime = t
sleep(delta_time)
}
assertTrue(useTime <= OpTimeout, "wait_for_latest_build_index_on_partition_finish timeout")
}

try {
Expand Down Expand Up @@ -162,12 +166,15 @@ suite("test_index_change_with_cumulative_compaction", "nonConcurrent") {
// build index
if (!isCloudMode()) {
sql "build index idx_user_id on ${tableName}"
wait_for_build_index_on_partition_finish(tableName, timeout)
sql "build index idx_date on ${tableName}"
wait_for_build_index_on_partition_finish(tableName, timeout)
sql "build index idx_city on ${tableName}"
wait_for_build_index_on_partition_finish(tableName, timeout)
}

// trigger compactions for all tablets in ${tableName}
trigger_compaction_with_retry(tableName, "cumulative")
trigger_and_wait_compaction(tableName, "cumulative")

int rowCount = 0
for (def tablet in tablets) {
Expand Down
Loading