From d1a15229621abfda144666db68a054b47b580b30 Mon Sep 17 00:00:00 2001 From: yangqise7en <877793735@qq.com> Date: Fri, 1 Mar 2024 03:45:02 +0000 Subject: [PATCH] fix can't generate parallel rowkey range for empty major --- src/share/ob_local_device.cpp | 8 ++++++-- src/share/scheduler/ob_dag_warning_history_mgr.h | 2 +- src/storage/compaction/ob_medium_compaction_func.cpp | 5 ++++- src/storage/compaction/ob_medium_compaction_mgr.cpp | 1 + src/storage/tablet/ob_tablet.cpp | 2 ++ 5 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/share/ob_local_device.cpp b/src/share/ob_local_device.cpp index bfa914d901..9fa0739bcd 100644 --- a/src/share/ob_local_device.cpp +++ b/src/share/ob_local_device.cpp @@ -64,8 +64,12 @@ int ObLocalIOEvents::get_ith_ret_code(const int64_t i) const int ObLocalIOEvents::get_ith_ret_bytes(const int64_t i) const { - const int64_t res = static_cast(io_events_[i].res); - return (nullptr != io_events_ && i < complete_io_cnt_ && res >= 0) ? static_cast(res) : 0; + int ret_val = 0; + if (nullptr != io_events_ && i < complete_io_cnt_) { + const int64_t res = static_cast(io_events_[i].res); + ret_val = res >= 0 ? static_cast(res) : 0; + } + return ret_val; } void *ObLocalIOEvents::get_ith_data(const int64_t i) const diff --git a/src/share/scheduler/ob_dag_warning_history_mgr.h b/src/share/scheduler/ob_dag_warning_history_mgr.h index 0bff916b40..58eb9c6639 100644 --- a/src/share/scheduler/ob_dag_warning_history_mgr.h +++ b/src/share/scheduler/ob_dag_warning_history_mgr.h @@ -161,7 +161,7 @@ private: if (__pos < buf_size) { \ buf[__pos-1] = '\0'; \ } else { \ - buf[__pos] = '\0'; \ + buf[buf_size - 1] = '\0'; \ } \ out_param = info_param; \ } \ diff --git a/src/storage/compaction/ob_medium_compaction_func.cpp b/src/storage/compaction/ob_medium_compaction_func.cpp index fe5d08e525..96af160779 100644 --- a/src/storage/compaction/ob_medium_compaction_func.cpp +++ b/src/storage/compaction/ob_medium_compaction_func.cpp @@ -693,15 +693,18 @@ int ObMediumCompactionScheduleFunc::init_parallel_range_and_schema_changed( } else { const int64_t macro_block_cnt = first_sstable->get_data_macro_block_count(); int64_t inc_row_cnt = 0; + int64_t inc_macro_cnt = 0; for (int64_t i = 0; OB_SUCC(ret) && i < result.handle_.get_count(); ++i) { inc_row_cnt += static_cast(result.handle_.get_table(i))->get_row_count(); + inc_macro_cnt += static_cast(result.handle_.get_table(i))->get_data_macro_block_count(); } if (OB_FAIL(ret)) { } else if ((0 == macro_block_cnt && inc_row_cnt > SCHEDULE_RANGE_ROW_COUNT_THRESHOLD) || (first_sstable->get_row_count() >= SCHEDULE_RANGE_ROW_COUNT_THRESHOLD && inc_row_cnt >= first_sstable->get_row_count() * SCHEDULE_RANGE_INC_ROW_COUNT_PERCENRAGE_THRESHOLD)) { - if (OB_FAIL(ObParallelMergeCtx::get_concurrent_cnt(tablet_size, macro_block_cnt, expected_task_count))) { + const int64_t estimate_macro_cnt = macro_block_cnt + inc_macro_cnt / 5; + if (OB_FAIL(ObParallelMergeCtx::get_concurrent_cnt(tablet_size, estimate_macro_cnt, expected_task_count))) { STORAGE_LOG(WARN, "failed to get concurrent cnt", K(ret), K(tablet_size), K(expected_task_count), KPC(first_sstable)); } diff --git a/src/storage/compaction/ob_medium_compaction_mgr.cpp b/src/storage/compaction/ob_medium_compaction_mgr.cpp index e5c326f68a..90bb39363e 100644 --- a/src/storage/compaction/ob_medium_compaction_mgr.cpp +++ b/src/storage/compaction/ob_medium_compaction_mgr.cpp @@ -249,6 +249,7 @@ int ObTabletMediumCompactionInfoRecorder::inner_replay_clog( } else if (OB_FAIL(replay_executor.execute(scn, ls_id_, tablet_id_))) { if (OB_TABLET_NOT_EXIST == ret || OB_NO_NEED_UPDATE == ret) { ret = OB_SUCCESS; + LOG_INFO("skip reply medium info", KR(ret), K(replay_medium_info)); } else { LOG_WARN("failed to replay medium info", K(ret), K(replay_medium_info)); } diff --git a/src/storage/tablet/ob_tablet.cpp b/src/storage/tablet/ob_tablet.cpp index 0744836f92..268d82f696 100644 --- a/src/storage/tablet/ob_tablet.cpp +++ b/src/storage/tablet/ob_tablet.cpp @@ -1101,6 +1101,8 @@ int ObTablet::init_with_update_medium_info( } else if (FALSE_IT(set_initial_addr())) { } else if (OB_FAIL(inner_inc_macro_ref_cnt())) { LOG_WARN("failed to increase macro ref cnt", K(ret)); + } else if (OB_FAIL(check_medium_list())) { + LOG_WARN("failed to check medium list", K(ret), KPC(this)); } else { ALLOC_AND_INIT(allocator, storage_schema_addr_, *old_storage_schema); if (OB_FAIL(ret)) {