From 3317d849ef29f9f1d2a51914fa664cafec418bbd Mon Sep 17 00:00:00 2001 From: a1iive Date: Thu, 1 Jun 2023 02:41:56 +0000 Subject: [PATCH] fix ls locality diagnose --- src/storage/compaction/ob_compaction_diagnose.cpp | 12 +++++++++++- .../compaction/ob_partition_merge_progress.cpp | 4 +++- .../compaction/ob_tenant_tablet_scheduler.cpp | 7 +++++-- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/storage/compaction/ob_compaction_diagnose.cpp b/src/storage/compaction/ob_compaction_diagnose.cpp index aa3d684a48..9ec0de4980 100644 --- a/src/storage/compaction/ob_compaction_diagnose.cpp +++ b/src/storage/compaction/ob_compaction_diagnose.cpp @@ -27,6 +27,7 @@ #include "rootserver/freeze/ob_major_freeze_util.h" #include "share/ob_tablet_meta_table_compaction_operator.h" #include "storage/compaction/ob_compaction_util.h" +#include "storage/compaction/ob_medium_compaction_func.h" #include "storage/tablet/ob_tablet.h" namespace oceanbase { @@ -483,6 +484,15 @@ int ObCompactionDiagnoseMgr::diagnose_tenant_tablet() LOG_WARN("failed to check ls state", K(tmp_ret), KPC(ls), K(need_merge)); } else if (need_merge) { const ObLSID &ls_id = ls->get_ls_id(); + bool is_leader = false; + ObRole role = INVALID_ROLE; + if (OB_TMP_FAIL(ObMediumCompactionScheduleFunc::get_palf_role(ls_id, role))) { + if (OB_LS_NOT_EXIST != tmp_ret) { + LOG_WARN("failed to get palf handle role", K(tmp_ret), K(ls_id)); + } + } else if (is_leader_by_election(role)) { + is_leader = true; + } bool weak_read_ts_ready = ObTenantTabletScheduler::check_weak_read_ts_ready(compaction_scn, *ls); // check weak read ts if (diagnose_major_flag @@ -505,7 +515,7 @@ int ObCompactionDiagnoseMgr::diagnose_tenant_tablet() } // check ls locality change and leader change - if (OB_TMP_FAIL(diagnose_ls_merge(MEDIUM_MERGE, ls_id))) { + if (is_leader && OB_TMP_FAIL(diagnose_ls_merge(MEDIUM_MERGE, ls_id))) { LOG_WARN("failed to diagnose about ls locality change", K(tmp_ret)); } ObLSTabletIterator tablet_iter(ObTabletCommon::NO_CHECK_GET_TABLET_TIMEOUT_US); diff --git a/src/storage/compaction/ob_partition_merge_progress.cpp b/src/storage/compaction/ob_partition_merge_progress.cpp index 1630492bdb..fbc74ab614 100644 --- a/src/storage/compaction/ob_partition_merge_progress.cpp +++ b/src/storage/compaction/ob_partition_merge_progress.cpp @@ -325,9 +325,11 @@ int ObPartitionMergeProgress::get_progress_info(ObCompactionProgress &input_prog { int ret = OB_SUCCESS; if (IS_INIT) { + int64_t estimate_unfinished_data_size = estimate_occupy_size_ - pre_scanned_row_cnt_ * avg_row_length_; input_progress.data_size_ = estimate_occupy_size_; input_progress.unfinished_data_size_ = - 0 == estimate_occupy_size_ ? 0 : estimate_occupy_size_ - pre_scanned_row_cnt_ * avg_row_length_; + 0 == estimate_occupy_size_ ? 0 : + (estimate_unfinished_data_size < 0 ? 0 : estimate_unfinished_data_size); input_progress.estimated_finish_time_ = estimated_finish_time_; } return ret; diff --git a/src/storage/compaction/ob_tenant_tablet_scheduler.cpp b/src/storage/compaction/ob_tenant_tablet_scheduler.cpp index a3905dc9d0..0d173981b5 100755 --- a/src/storage/compaction/ob_tenant_tablet_scheduler.cpp +++ b/src/storage/compaction/ob_tenant_tablet_scheduler.cpp @@ -947,6 +947,7 @@ int ObTenantTabletScheduler::schedule_ls_medium_merge( int tmp_ret = OB_SUCCESS; bool is_leader = false; bool could_major_merge = false; + bool locality_bad_case = false; const int64_t major_frozen_scn = get_frozen_version(); ObRole role = INVALID_ROLE; ObLSLocality ls_locality; @@ -968,10 +969,9 @@ int ObTenantTabletScheduler::schedule_ls_medium_merge( LOG_WARN("failed to get ls locality", K(ret), K(ls_id)); } else if (ls_locality.is_valid()) { if (!ls_locality.check_exist(GCTX.self_addr())) { + locality_bad_case = true; ADD_SUSPECT_INFO(MEDIUM_MERGE, ls_id, ObTabletID(INT64_MAX), "maybe bad case: ls leader is not in ls locality", "leader_addr", GCTX.self_addr(), K(ls_locality)); - } else { - DEL_SUSPECT_INFO(MEDIUM_MERGE, ls_id, ObTabletID(INT64_MAX)); } } } @@ -979,6 +979,9 @@ int ObTenantTabletScheduler::schedule_ls_medium_merge( all_ls_weak_read_ts_ready = false; } } + if (!locality_bad_case) { + DEL_SUSPECT_INFO(MEDIUM_MERGE, ls_id, ObTabletID(INT64_MAX)); + } while (OB_SUCC(ret) && schedule_tablet_cnt < SCHEDULE_TABLET_BATCH_CNT) { // loop all tablet in ls bool tablet_merge_finish = false;