From 62c47a32945cf9c31ac36df89d023b16c7a9027f Mon Sep 17 00:00:00 2001 From: a1iive Date: Thu, 14 Dec 2023 11:22:29 +0000 Subject: [PATCH] forbid to schedule_compaction_after_mini when restoring --- .../compaction/ob_tablet_merge_ctx.cpp | 33 +++++++++++-------- .../compaction/ob_tenant_tablet_scheduler.cpp | 30 +++++++++++++++++ .../compaction/ob_tenant_tablet_scheduler.h | 4 +++ .../ob_tenant_tablet_scheduler_task_mgr.cpp | 3 ++ 4 files changed, 56 insertions(+), 14 deletions(-) diff --git a/src/storage/compaction/ob_tablet_merge_ctx.cpp b/src/storage/compaction/ob_tablet_merge_ctx.cpp index ffb1098c1..b44fa520a 100644 --- a/src/storage/compaction/ob_tablet_merge_ctx.cpp +++ b/src/storage/compaction/ob_tablet_merge_ctx.cpp @@ -156,24 +156,29 @@ int ObTabletMiniMergeCtx::update_tablet( void ObTabletMiniMergeCtx::try_schedule_compaction_after_mini(ObTabletHandle &tablet_handle) { int tmp_ret = OB_SUCCESS; + bool is_restore = false; bool create_meta_dag = false; + // when restoring, some log stream may be not ready, + // thus the inner sql in ObTenantFreezeInfoMgr::try_update_info may timeout + if (!MTL(ObTenantTabletScheduler *)->is_restore()) { + if (get_tablet_id().is_ls_inner_tablet() || + 0 == get_merge_info().get_sstable_merge_info().macro_block_count_) { + // do nothing + } else if (OB_TMP_FAIL(try_schedule_meta_merge(tablet_handle, create_meta_dag))) { + LOG_WARN_RET(tmp_ret, "failed to schedule meta merge", K(get_dag_param())); + } - if (get_tablet_id().is_ls_inner_tablet() || - 0 == get_merge_info().get_sstable_merge_info().macro_block_count_) { - // do nothing - } else if (OB_TMP_FAIL(try_schedule_meta_merge(tablet_handle, create_meta_dag))) { - LOG_WARN_RET(tmp_ret, "failed to schedule meta merge", K(get_dag_param())); - } - - if (create_meta_dag || 0 == get_merge_info().get_sstable_merge_info().macro_block_count_) { - // no need to schedule minor merge - } else if (OB_TMP_FAIL(ObTenantTabletScheduler::schedule_tablet_minor_merge( - static_param_.ls_handle_, tablet_handle))) { - if (OB_SIZE_OVERFLOW != tmp_ret) { - LOG_WARN_RET(tmp_ret, "failed to schedule special tablet minor merge", - "ls_id", get_ls_id(), "tablet_id", get_tablet_id()); + if (create_meta_dag || 0 == get_merge_info().get_sstable_merge_info().macro_block_count_) { + // no need to schedule minor merge + } else if (OB_TMP_FAIL(ObTenantTabletScheduler::schedule_tablet_minor_merge( + static_param_.ls_handle_, tablet_handle))) { + if (OB_SIZE_OVERFLOW != tmp_ret) { + LOG_WARN_RET(tmp_ret, "failed to schedule special tablet minor merge", + "ls_id", get_ls_id(), "tablet_id", get_tablet_id()); + } } } + time_guard_click(ObStorageCompactionTimeGuard::SCHEDULE_OTHER_COMPACTION); } diff --git a/src/storage/compaction/ob_tenant_tablet_scheduler.cpp b/src/storage/compaction/ob_tenant_tablet_scheduler.cpp index 05490c3a5..9ae8a66a1 100644 --- a/src/storage/compaction/ob_tenant_tablet_scheduler.cpp +++ b/src/storage/compaction/ob_tenant_tablet_scheduler.cpp @@ -203,6 +203,7 @@ ObTenantTabletScheduler::ObTenantTabletScheduler() : is_inited_(false), major_merge_status_(false), is_stop_(false), + is_restore_(false), enable_adaptive_compaction_(false), enable_adaptive_merge_schedule_(false), bf_queue_(), @@ -512,6 +513,35 @@ int ObTenantTabletScheduler::set_max() return ret; } +int ObTenantTabletScheduler::refresh_tenant_status() +{ + int ret = OB_SUCCESS; + int tmp_ret = OB_SUCCESS; + if (IS_NOT_INIT) { + ret = OB_NOT_INIT; + LOG_WARN("The ObTenantTabletScheduler has not been inited", K(ret)); + } else { + // refresh is_restore + if (REACH_TENANT_TIME_INTERVAL(REFRESH_TENANT_STATUS_INTERVAL)) { + ATOMIC_SET(&is_restore_, false); + ObSchemaGetterGuard schema_guard; + const ObSimpleTenantSchema *tenant_schema = nullptr; + const int64_t tenant_id = MTL_ID(); + if (OB_TMP_FAIL(GCTX.schema_service_->get_tenant_schema_guard(tenant_id, schema_guard))) { + LOG_WARN("fail to get schema guard", K(tmp_ret), K(tenant_id)); + } else if (OB_TMP_FAIL(schema_guard.get_tenant_info(tenant_id, tenant_schema))) { + LOG_WARN("fail to get tenant schema", K(tmp_ret), K(tenant_id)); + } else if (OB_ISNULL(tenant_schema)) { + tmp_ret = OB_SCHEMA_ERROR; + LOG_WARN("tenant schema is null", K(tmp_ret)); + } else if (tenant_schema->is_restore()) { + ATOMIC_SET(&is_restore_, true); + } + } + } + return ret; +} + int ObTenantTabletScheduler::schedule_build_bloomfilter( const uint64_t table_id, const blocksstable::MacroBlockId ¯o_id, diff --git a/src/storage/compaction/ob_tenant_tablet_scheduler.h b/src/storage/compaction/ob_tenant_tablet_scheduler.h index cb72d13e8..bdbbfa87f 100644 --- a/src/storage/compaction/ob_tenant_tablet_scheduler.h +++ b/src/storage/compaction/ob_tenant_tablet_scheduler.h @@ -152,6 +152,7 @@ public: void stop_major_merge(); void resume_major_merge(); OB_INLINE bool could_major_merge_start() const { return ATOMIC_LOAD(&major_merge_status_); } + OB_INLINE bool is_restore() const { return ATOMIC_LOAD(&is_restore_); } // The transfer task sets the flag that prohibits the scheduling of medium when the log stream is src_ls of transfer int stop_tablets_schedule_medium(const ObIArray &tablet_ids, const ObProhibitScheduleMediumMap::ProhibitFlag &input_flag); int clear_tablets_prohibit_medium_flag(const ObIArray &tablet_ids, const ObProhibitScheduleMediumMap::ProhibitFlag &input_flag); @@ -179,6 +180,7 @@ public: int gc_info(); int set_max(); + int refresh_tenant_status(); // Schedule an async task to build bloomfilter for the given macro block. // The bloomfilter build task will be ignored if a same build task exists in the queue. int schedule_build_bloomfilter( @@ -305,11 +307,13 @@ private: static const int64_t ADD_LOOP_EVENT_INTERVAL = 120 * 1000 * 1000L; // 120s static const int64_t PRINT_LOG_INVERVAL = 2 * 60 * 1000 * 1000L; // 2m static const int64_t WAIT_MEDIUM_CHECK_THRESHOLD = 10 * 60 * 1000 * 1000 * 1000L; // 10m + static const int64_t REFRESH_TENANT_STATUS_INTERVAL = 30 * 1000 * 1000L; // 30s static const int64_t MERGE_BACTH_FREEZE_CNT = 100L; private: bool is_inited_; bool major_merge_status_; bool is_stop_; + bool is_restore_; bool enable_adaptive_compaction_; bool enable_adaptive_merge_schedule_; common::ObDedupQueue bf_queue_; diff --git a/src/storage/compaction/ob_tenant_tablet_scheduler_task_mgr.cpp b/src/storage/compaction/ob_tenant_tablet_scheduler_task_mgr.cpp index 855020dea..e30fe0e2d 100644 --- a/src/storage/compaction/ob_tenant_tablet_scheduler_task_mgr.cpp +++ b/src/storage/compaction/ob_tenant_tablet_scheduler_task_mgr.cpp @@ -139,6 +139,9 @@ void ObTenantTabletSchedulerTaskMgr::InfoPoolResizeTask::runTimerTask() if (OB_FAIL(MTL(ObTenantCGReadInfoMgr *)->gc_cg_info_array())) { LOG_WARN("Fail to gc info", K(ret)); } + if (OB_FAIL(MTL(ObTenantTabletScheduler *)->refresh_tenant_status())) { + LOG_WARN("Fail to refresh tenant status", K(ret)); + } cost_ts = ObTimeUtility::fast_current_time() - cost_ts; LOG_INFO("InfoPoolResizeTask", K(cost_ts)); }