From 86b40ebc71896a6988d431152711c224d3e2193a Mon Sep 17 00:00:00 2001 From: xxyd <3120103729@zju.edu.cn> Date: Wed, 11 Dec 2024 03:18:02 +0000 Subject: [PATCH] [CP] fix spm add baseline concurrent bug --- src/sql/ob_sql.cpp | 7 +++---- src/sql/ob_sql_utils.cpp | 2 -- src/sql/spm/ob_plan_baseline_mgr.h | 1 - src/sql/spm/ob_spm_controller.h | 1 - src/sql/spm/ob_spm_define.h | 5 +---- 5 files changed, 4 insertions(+), 12 deletions(-) diff --git a/src/sql/ob_sql.cpp b/src/sql/ob_sql.cpp index e7d1fee91..2541c61c1 100644 --- a/src/sql/ob_sql.cpp +++ b/src/sql/ob_sql.cpp @@ -5234,9 +5234,6 @@ OB_NOINLINE int ObSql::handle_physical_plan(const ObString &trimed_stmt, // baseline and execute this plan directly. need_get_baseline = false; spm_ctx.baseline_exists_ = false; - } else { - // add baseline plan failed, need evict unaccepted baseline in baseline cache. - (void) ObSpmController::deny_new_plan_as_baseline(spm_ctx); } } else if (plan_added && ObSpmCacheCtx::SpmStat::STAT_ADD_BASELINE_PLAN == spm_ctx.spm_stat_) { if ((nullptr != spm_ctx.baseline_guard_.get_cache_obj() && @@ -5284,7 +5281,9 @@ OB_NOINLINE int ObSql::handle_physical_plan(const ObString &trimed_stmt, } else if (!plan_added) { // plan not add to plan cache, do not check if need evolution. if (spm_ctx.check_execute_status_) { - (void) ObSpmController::deny_new_plan_as_baseline(spm_ctx); + // session which add plan succeed need check execute status + spm_ctx.check_execute_status_ = false; + LOG_TRACE("plan not add, disable check execute status"); } } else if (baseline_enable && !baseline_exists) { need_get_baseline = true; diff --git a/src/sql/ob_sql_utils.cpp b/src/sql/ob_sql_utils.cpp index d11e2089a..885175537 100644 --- a/src/sql/ob_sql_utils.cpp +++ b/src/sql/ob_sql_utils.cpp @@ -6051,8 +6051,6 @@ int ObSQLUtils::handle_plan_baseline(const ObAuditRecordData &audit_record, if (OB_FAIL(ObSpmController::accept_new_plan_as_baseline(sql_ctx.spm_ctx_, audit_record))) { LOG_WARN("failed to accept new plan as baseline", K(ret)); } - } else if (OB_FAIL(ObSpmController::deny_new_plan_as_baseline(sql_ctx.spm_ctx_))) { - LOG_WARN("failed to deny new plan as baseline", K(ret)); } return ret; } diff --git a/src/sql/spm/ob_plan_baseline_mgr.h b/src/sql/spm/ob_plan_baseline_mgr.h index 7dabcdbd9..c088f6bdd 100644 --- a/src/sql/spm/ob_plan_baseline_mgr.h +++ b/src/sql/spm/ob_plan_baseline_mgr.h @@ -137,7 +137,6 @@ public: int64_t &baseline_affected); int load_baseline(ObSpmBaselineLoader &baseline_loader); int purge_baselines(const uint64_t tenant_id, int64_t baseline_affected); - int evict_plan_baseline(ObSpmCacheCtx& spm_ctx); int check_evolution_task(); int handle_spm_evo_record(const uint64_t tenant_id); private: diff --git a/src/sql/spm/ob_spm_controller.h b/src/sql/spm/ob_spm_controller.h index 5421ad1d8..cdcb70b71 100644 --- a/src/sql/spm/ob_spm_controller.h +++ b/src/sql/spm/ob_spm_controller.h @@ -41,7 +41,6 @@ public: static int accept_plan_baseline_by_user(obrpc::ObModifyPlanBaselineArg& arg); static int cancel_evolve_task(obrpc::ObModifyPlanBaselineArg& arg); static int load_baseline(ObSpmBaselineLoader &baseline_loader); - static int deny_new_plan_as_baseline(ObSpmCacheCtx& spm_ctx); static int64_t calc_spm_timeout_us(const int64_t normal_timeout, const int64_t baseline_exec_time); }; diff --git a/src/sql/spm/ob_spm_define.h b/src/sql/spm/ob_spm_define.h index 9fc521b41..3163cf60b 100644 --- a/src/sql/spm/ob_spm_define.h +++ b/src/sql/spm/ob_spm_define.h @@ -105,7 +105,6 @@ public: executions_(0), elapsed_time_(UINT64_MAX), cpu_time_( UINT64_MAX), - need_evict_(false), need_sync_(false) {} virtual ~ObPlanBaselineItem() { destroy(); } @@ -178,8 +177,6 @@ public: inline void set_elapsed_time(int64_t v) { elapsed_time_ = v; } inline int64_t get_cpu_time() const { return cpu_time_; } inline void set_cpu_time(int64_t v) { cpu_time_ = v; } - inline bool get_need_evict() const { return need_evict_; } - inline void set_need_evict(bool v) { need_evict_ = v; } inline bool get_need_sync() const { return need_sync_; } inline void set_need_sync(bool v) { need_sync_ = v; } @@ -207,7 +204,6 @@ public: int64_t cpu_time_; // The total CPU time consumed during the evolution process // common::ObString hints_info_; // for lib cache management - bool need_evict_; bool need_sync_; private: DISALLOW_COPY_AND_ASSIGN(ObPlanBaselineItem); @@ -238,6 +234,7 @@ public: void destroy(); void set_baseline_key(ObBaselineKey &key) { baseline_key_ = key; } ObBaselineKey &get_baseline_key() { return baseline_key_; } + bool check_has_accepted_baseline() const; TO_STRING_KV(K_(is_inited)); private: