fix plan cache not sharing plan at weak read
This commit is contained in:
@ -627,7 +627,8 @@ int ObPlanCache::construct_fast_parser_result(common::ObIAllocator &allocator,
|
|||||||
&(pc_ctx.exec_ctx_.get_physical_plan_ctx()->get_param_store_for_update());
|
&(pc_ctx.exec_ctx_.get_physical_plan_ctx()->get_param_store_for_update());
|
||||||
if (OB_FAIL(construct_plan_cache_key(*pc_ctx.sql_ctx_.session_info_,
|
if (OB_FAIL(construct_plan_cache_key(*pc_ctx.sql_ctx_.session_info_,
|
||||||
ObLibCacheNameSpace::NS_CRSR,
|
ObLibCacheNameSpace::NS_CRSR,
|
||||||
fp_result.pc_key_))) {
|
fp_result.pc_key_,
|
||||||
|
pc_ctx.sql_ctx_.is_protocol_weak_read_))) {
|
||||||
LOG_WARN("failed to construct plan cache key", K(ret));
|
LOG_WARN("failed to construct plan cache key", K(ret));
|
||||||
} else if (enable_exact_mode) {
|
} else if (enable_exact_mode) {
|
||||||
(void)fp_result.pc_key_.name_.assign_ptr(raw_sql.ptr(), raw_sql.length());
|
(void)fp_result.pc_key_.name_.assign_ptr(raw_sql.ptr(), raw_sql.length());
|
||||||
@ -1799,7 +1800,8 @@ int ObPlanCache::construct_plan_cache_key(ObPlanCacheCtx &plan_ctx, ObLibCacheNa
|
|||||||
LOG_WARN("session info is null");
|
LOG_WARN("session info is null");
|
||||||
} else if (OB_FAIL(construct_plan_cache_key(*session,
|
} else if (OB_FAIL(construct_plan_cache_key(*session,
|
||||||
ns,
|
ns,
|
||||||
plan_ctx.fp_result_.pc_key_))) {
|
plan_ctx.fp_result_.pc_key_,
|
||||||
|
plan_ctx.sql_ctx_.is_protocol_weak_read_))) {
|
||||||
LOG_WARN("failed to construct plan cache key", K(ret));
|
LOG_WARN("failed to construct plan cache key", K(ret));
|
||||||
} else {
|
} else {
|
||||||
plan_ctx.key_ = &(plan_ctx.fp_result_.pc_key_);
|
plan_ctx.key_ = &(plan_ctx.fp_result_.pc_key_);
|
||||||
@ -1809,7 +1811,8 @@ int ObPlanCache::construct_plan_cache_key(ObPlanCacheCtx &plan_ctx, ObLibCacheNa
|
|||||||
|
|
||||||
OB_INLINE int ObPlanCache::construct_plan_cache_key(ObSQLSessionInfo &session,
|
OB_INLINE int ObPlanCache::construct_plan_cache_key(ObSQLSessionInfo &session,
|
||||||
ObLibCacheNameSpace ns,
|
ObLibCacheNameSpace ns,
|
||||||
ObPlanCacheKey &pc_key)
|
ObPlanCacheKey &pc_key,
|
||||||
|
bool is_weak)
|
||||||
{
|
{
|
||||||
int ret = OB_SUCCESS;
|
int ret = OB_SUCCESS;
|
||||||
uint64_t database_id = OB_INVALID_ID;
|
uint64_t database_id = OB_INVALID_ID;
|
||||||
@ -1818,8 +1821,8 @@ OB_INLINE int ObPlanCache::construct_plan_cache_key(ObSQLSessionInfo &session,
|
|||||||
pc_key.namespace_ = ns;
|
pc_key.namespace_ = ns;
|
||||||
pc_key.sys_vars_str_ = session.get_sys_var_in_pc_str();
|
pc_key.sys_vars_str_ = session.get_sys_var_in_pc_str();
|
||||||
pc_key.config_str_ = session.get_config_in_pc_str();
|
pc_key.config_str_ = session.get_config_in_pc_str();
|
||||||
|
pc_key.is_weak_read_ = is_weak;
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int ObPlanCache::need_late_compile(ObPhysicalPlan *plan,
|
int ObPlanCache::need_late_compile(ObPhysicalPlan *plan,
|
||||||
|
|||||||
@ -412,7 +412,8 @@ private:
|
|||||||
int construct_plan_cache_key(ObPlanCacheCtx &plan_ctx, ObLibCacheNameSpace ns);
|
int construct_plan_cache_key(ObPlanCacheCtx &plan_ctx, ObLibCacheNameSpace ns);
|
||||||
static int construct_plan_cache_key(ObSQLSessionInfo &session,
|
static int construct_plan_cache_key(ObSQLSessionInfo &session,
|
||||||
ObLibCacheNameSpace ns,
|
ObLibCacheNameSpace ns,
|
||||||
ObPlanCacheKey &pc_key);
|
ObPlanCacheKey &pc_key,
|
||||||
|
bool is_weak);
|
||||||
/**
|
/**
|
||||||
* @brief wether jit compilation is needed in this sql
|
* @brief wether jit compilation is needed in this sql
|
||||||
*
|
*
|
||||||
|
|||||||
@ -55,7 +55,8 @@ struct ObPlanCacheKey : public ObILibCacheKey
|
|||||||
: key_id_(common::OB_INVALID_ID),
|
: key_id_(common::OB_INVALID_ID),
|
||||||
db_id_(common::OB_INVALID_ID),
|
db_id_(common::OB_INVALID_ID),
|
||||||
sessid_(0),
|
sessid_(0),
|
||||||
mode_(PC_TEXT_MODE) {}
|
mode_(PC_TEXT_MODE),
|
||||||
|
is_weak_read_(false) {}
|
||||||
|
|
||||||
inline void reset()
|
inline void reset()
|
||||||
{
|
{
|
||||||
@ -66,6 +67,7 @@ struct ObPlanCacheKey : public ObILibCacheKey
|
|||||||
mode_ = PC_TEXT_MODE;
|
mode_ = PC_TEXT_MODE;
|
||||||
sys_vars_str_.reset();
|
sys_vars_str_.reset();
|
||||||
config_str_.reset();
|
config_str_.reset();
|
||||||
|
is_weak_read_ = false;
|
||||||
namespace_ = NS_INVALID;
|
namespace_ = NS_INVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,6 +92,7 @@ struct ObPlanCacheKey : public ObILibCacheKey
|
|||||||
sessid_ = pc_key.sessid_;
|
sessid_ = pc_key.sessid_;
|
||||||
mode_ = pc_key.mode_;
|
mode_ = pc_key.mode_;
|
||||||
namespace_ = pc_key.namespace_;
|
namespace_ = pc_key.namespace_;
|
||||||
|
is_weak_read_ = pc_key.is_weak_read_;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -130,6 +133,7 @@ struct ObPlanCacheKey : public ObILibCacheKey
|
|||||||
mode_ == pc_key.mode_ &&
|
mode_ == pc_key.mode_ &&
|
||||||
sys_vars_str_ == pc_key.sys_vars_str_ &&
|
sys_vars_str_ == pc_key.sys_vars_str_ &&
|
||||||
config_str_ == pc_key.config_str_ &&
|
config_str_ == pc_key.config_str_ &&
|
||||||
|
is_weak_read_ == pc_key.is_weak_read_ &&
|
||||||
namespace_ == pc_key.namespace_;
|
namespace_ == pc_key.namespace_;
|
||||||
|
|
||||||
return cmp_ret;
|
return cmp_ret;
|
||||||
@ -141,6 +145,7 @@ struct ObPlanCacheKey : public ObILibCacheKey
|
|||||||
K_(mode),
|
K_(mode),
|
||||||
K_(sys_vars_str),
|
K_(sys_vars_str),
|
||||||
K_(config_str),
|
K_(config_str),
|
||||||
|
K_(is_weak_read),
|
||||||
K_(namespace));
|
K_(namespace));
|
||||||
//通过name来进行查找,一般是shared sql/procedure
|
//通过name来进行查找,一般是shared sql/procedure
|
||||||
//cursor用这种方式,对应的namespace是CRSR
|
//cursor用这种方式,对应的namespace是CRSR
|
||||||
@ -153,6 +158,7 @@ struct ObPlanCacheKey : public ObILibCacheKey
|
|||||||
PlanCacheMode mode_;
|
PlanCacheMode mode_;
|
||||||
common::ObString sys_vars_str_;
|
common::ObString sys_vars_str_;
|
||||||
common::ObString config_str_;
|
common::ObString config_str_;
|
||||||
|
bool is_weak_read_;
|
||||||
};
|
};
|
||||||
|
|
||||||
//记录快速化参数后不需要扣参数的原始字符串及相关信息
|
//记录快速化参数后不需要扣参数的原始字符串及相关信息
|
||||||
|
|||||||
Reference in New Issue
Block a user