From 9710bb145a9aae49d2eb9a5cc4daebbd97e84e15 Mon Sep 17 00:00:00 2001 From: lf0 Date: Mon, 7 Feb 2022 18:57:42 +0800 Subject: [PATCH] Fix core at plan cache ObCacheObject::pre_calculation --- src/sql/engine/ob_physical_plan_ctx.cpp | 7 +++++++ src/sql/engine/ob_physical_plan_ctx.h | 1 + src/sql/plan_cache/ob_plan_cache.cpp | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/src/sql/engine/ob_physical_plan_ctx.cpp b/src/sql/engine/ob_physical_plan_ctx.cpp index c1a1713102..47ee9d1243 100644 --- a/src/sql/engine/ob_physical_plan_ctx.cpp +++ b/src/sql/engine/ob_physical_plan_ctx.cpp @@ -86,6 +86,13 @@ ObPhysicalPlanCtx::ObPhysicalPlanCtx(common::ObIAllocator& allocator) ObPhysicalPlanCtx::~ObPhysicalPlanCtx() {} +void ObPhysicalPlanCtx::restore_param_store(const int64_t original_param_cnt) +{ + for (int64_t i = param_store_.count(); i > original_param_cnt; --i) { + param_store_.pop_back(); + } +} + int ObPhysicalPlanCtx::reserve_param_space(int64_t param_count) { int ret = OB_SUCCESS; diff --git a/src/sql/engine/ob_physical_plan_ctx.h b/src/sql/engine/ob_physical_plan_ctx.h index acd3cc7d77..ff931cf1d9 100644 --- a/src/sql/engine/ob_physical_plan_ctx.h +++ b/src/sql/engine/ob_physical_plan_ctx.h @@ -135,6 +135,7 @@ public: { return consistency_level_; } + void restore_param_store(const int64_t param_count); // param store int reserve_param_space(int64_t param_count); const ParamStore& get_param_store() const diff --git a/src/sql/plan_cache/ob_plan_cache.cpp b/src/sql/plan_cache/ob_plan_cache.cpp index 1d8b47ff0f..2dd29a1cf4 100644 --- a/src/sql/plan_cache/ob_plan_cache.cpp +++ b/src/sql/plan_cache/ob_plan_cache.cpp @@ -1496,6 +1496,7 @@ int ObPlanCache::get_ps_plan( UNUSED(stmt_id); ObSqlTraits sql_traits; ObCacheObject* cache_obj = NULL; + int64_t original_param_cnt = 0; pc_ctx.handle_id_ = ref_handle; if (OB_ISNULL(pc_ctx.sql_ctx_.session_info_) || OB_ISNULL(pc_ctx.sql_ctx_.schema_guard_) || OB_ISNULL(pc_ctx.exec_ctx_.get_physical_plan_ctx())) { @@ -1509,6 +1510,8 @@ int ObPlanCache::get_ps_plan( } else if (FALSE_IT(pc_ctx.fp_result_.cache_params_ = &(pc_ctx.exec_ctx_.get_physical_plan_ctx()->get_param_store_for_update()))) { // do nothing + } else if (FALSE_IT(original_param_cnt = pc_ctx.fp_result_.cache_params_->count())) { + // do nothing } else if (OB_FAIL(construct_plan_cache_key(pc_ctx, NS_CRSR))) { LOG_WARN("fail to construnct plan cache key", K(ret)); } else if (OB_FAIL(get_cache_obj(pc_ctx, cache_obj))) { @@ -1528,6 +1531,7 @@ int ObPlanCache::get_ps_plan( ObPsStmtId new_stmt_id = pc_ctx.fp_result_.pc_key_.key_id_; pc_ctx.fp_result_.pc_key_.key_id_ = OB_INVALID_ID; pc_ctx.fp_result_.pc_key_.name_ = pc_ctx.raw_sql_; + pc_ctx.exec_ctx_.get_physical_plan_ctx()->restore_param_store(original_param_cnt); SQL_PC_LOG( DEBUG, "start to get plan by sql", K(new_stmt_id), K(pc_ctx.fp_result_.pc_key_), K(sql_pcvs_map_.size())); if (OB_FAIL(get_cache_obj(pc_ctx, cache_obj))) { -- GitLab