fix add plan hang caused by resource manager evict plan

This commit is contained in:
obdev
2023-01-12 15:13:17 +00:00
committed by OB-robot
parent a8504f099a
commit 4799992a7f
3 changed files with 10 additions and 3 deletions

View File

@ -650,7 +650,7 @@ int ObPlanCache::add_plan_cache(ObILibCacheCtx &ctx,
SQL_PC_LOG(WARN, "fail to remove lib cache node", K(ret)); SQL_PC_LOG(WARN, "fail to remove lib cache node", K(ret));
} }
} }
} while (OB_OLD_SCHEMA_VERSION == ret); } while (OB_OLD_SCHEMA_VERSION == ret && pc_ctx.need_retry_add_plan());
} }
return ret; return ret;
} }

View File

@ -327,7 +327,8 @@ struct ObPlanCacheCtx : public ObILibCacheCtx
def_name_ctx_(NULL), def_name_ctx_(NULL),
fixed_param_info_list_(allocator), fixed_param_info_list_(allocator),
dynamic_param_info_list_(allocator), dynamic_param_info_list_(allocator),
tpl_sql_const_cons_(allocator) tpl_sql_const_cons_(allocator),
need_retry_add_plan_(true)
{ {
fp_result_.pc_key_.mode_ = mode_; fp_result_.pc_key_.mode_ = mode_;
} }
@ -383,6 +384,8 @@ struct ObPlanCacheCtx : public ObILibCacheCtx
bool is_inner_sql() const { return is_inner_sql_; } bool is_inner_sql() const { return is_inner_sql_; }
void set_is_rewrite_sql(bool v) { is_rewrite_sql_ = v; } void set_is_rewrite_sql(bool v) { is_rewrite_sql_ = v; }
bool is_rewrite_sql() const { return is_rewrite_sql_; } bool is_rewrite_sql() const { return is_rewrite_sql_; }
void set_need_retry_add_plan(bool v) { need_retry_add_plan_ = v; }
bool need_retry_add_plan() const { return need_retry_add_plan_; }
TO_STRING_KV( TO_STRING_KV(
K(mode_), K(mode_),
K(raw_sql_), K(raw_sql_),
@ -405,7 +408,8 @@ struct ObPlanCacheCtx : public ObILibCacheCtx
K(fixed_param_info_list_), K(fixed_param_info_list_),
K(dynamic_param_info_list_), K(dynamic_param_info_list_),
K(tpl_sql_const_cons_), K(tpl_sql_const_cons_),
K(is_original_ps_mode_) K(is_original_ps_mode_),
K(need_retry_add_plan_)
); );
PlanCacheMode mode_; //control use which variables to do match PlanCacheMode mode_; //control use which variables to do match
@ -463,6 +467,8 @@ struct ObPlanCacheCtx : public ObILibCacheCtx
common::ObFixedArray<DynamicParamInfo, common::ObIAllocator> dynamic_param_info_list_; common::ObFixedArray<DynamicParamInfo, common::ObIAllocator> dynamic_param_info_list_;
common::ObFixedArray<NotParamInfoList, common::ObIAllocator> tpl_sql_const_cons_; common::ObFixedArray<NotParamInfoList, common::ObIAllocator> tpl_sql_const_cons_;
// ********** for rewrite end ********** // ********** for rewrite end **********
// when schema version of cache node is old, whether remove this node and retry add cache obj.
bool need_retry_add_plan_;
}; };
struct ObPlanCacheStat struct ObPlanCacheStat

View File

@ -1104,6 +1104,7 @@ int ObPlanCacheValue::add_plan(ObPlanCacheObject &plan,
int64_t latest_rule_version = G_RES_MGR.get_col_mapping_rule_mgr().get_column_mapping_version(MTL_ID()); int64_t latest_rule_version = G_RES_MGR.get_col_mapping_rule_mgr().get_column_mapping_version(MTL_ID());
if (pc_ctx.sql_ctx_.res_map_rule_version_ != latest_rule_version) { if (pc_ctx.sql_ctx_.res_map_rule_version_ != latest_rule_version) {
ret = OB_OLD_SCHEMA_VERSION; ret = OB_OLD_SCHEMA_VERSION;
pc_ctx.set_need_retry_add_plan(false);
SQL_PC_LOG(TRACE, "resource map rule version is outdated, not add to plan cache.", K(ret), SQL_PC_LOG(TRACE, "resource map rule version is outdated, not add to plan cache.", K(ret),
K(pc_ctx.sql_ctx_.res_map_rule_version_), K(latest_rule_version)); K(pc_ctx.sql_ctx_.res_map_rule_version_), K(latest_rule_version));
} }