Support timing auto flush plan cache
This commit is contained in:
@ -1312,3 +1312,6 @@ ERRSIM_DEF_STR(errsim_migration_src_server_addr, OB_CLUSTER_PARAMETER, "",
|
|||||||
DEF_BOOL(enable_cgroup, OB_CLUSTER_PARAMETER, "True",
|
DEF_BOOL(enable_cgroup, OB_CLUSTER_PARAMETER, "True",
|
||||||
"when set to false, cgroup will not init; when set to true but cgroup root dir is not ready, print ERROR",
|
"when set to false, cgroup will not init; when set to true but cgroup root dir is not ready, print ERROR",
|
||||||
ObParameterAttr(Section::OBSERVER, Source::DEFAULT, EditLevel::STATIC_EFFECTIVE));
|
ObParameterAttr(Section::OBSERVER, Source::DEFAULT, EditLevel::STATIC_EFFECTIVE));
|
||||||
|
DEF_TIME(_ob_plan_cache_auto_flush_interval, OB_CLUSTER_PARAMETER, "0s", "[0s,)",
|
||||||
|
"time interval for auto periodic flush plan cache. Range: [0s, +∞)",
|
||||||
|
ObParameterAttr(Section::OBSERVER, Source::DEFAULT, EditLevel::DYNAMIC_EFFECTIVE));
|
||||||
@ -277,17 +277,24 @@ int ObPlanCacheManager::revert_plan_cache(const uint64_t &tenant_id)
|
|||||||
|
|
||||||
void ObPlanCacheManager::ObPlanCacheEliminationTask::runTimerTask()
|
void ObPlanCacheManager::ObPlanCacheEliminationTask::runTimerTask()
|
||||||
{
|
{
|
||||||
|
#define NEED_AUTO_FLUSH_PC(v) (0 == v ? false : true)
|
||||||
int ret = OB_SUCCESS;
|
int ret = OB_SUCCESS;
|
||||||
if (OB_ISNULL(plan_cache_manager_)) {
|
if (OB_ISNULL(plan_cache_manager_)) {
|
||||||
ret = OB_NOT_INIT;
|
ret = OB_NOT_INIT;
|
||||||
SQL_PC_LOG(WARN, "plan_cache_manager not inited", K(ret));
|
SQL_PC_LOG(WARN, "plan_cache_manager not inited", K(ret));
|
||||||
} else {
|
} else {
|
||||||
|
++run_task_counter_;
|
||||||
|
const int64_t auto_flush_pc_interval = (int64_t)(GCONF._ob_plan_cache_auto_flush_interval) / (1000 * 1000L); // second
|
||||||
{
|
{
|
||||||
// 在调用plan cache接口前引用plan资源前必须定义guard
|
// 在调用plan cache接口前引用plan资源前必须定义guard
|
||||||
observer::ObReqTimeGuard req_timeinfo_guard;
|
observer::ObReqTimeGuard req_timeinfo_guard;
|
||||||
|
|
||||||
run_plan_cache_task();
|
run_plan_cache_task();
|
||||||
run_ps_cache_task();
|
run_ps_cache_task();
|
||||||
|
if (NEED_AUTO_FLUSH_PC(auto_flush_pc_interval)
|
||||||
|
&& 0 == run_task_counter_ % auto_flush_pc_interval) {
|
||||||
|
run_auto_flush_plan_cache_task();
|
||||||
|
}
|
||||||
SQL_PC_LOG(INFO, "schedule next cache evict task",
|
SQL_PC_LOG(INFO, "schedule next cache evict task",
|
||||||
"evict_interval", (int64_t)(GCONF.plan_cache_evict_interval));
|
"evict_interval", (int64_t)(GCONF.plan_cache_evict_interval));
|
||||||
}
|
}
|
||||||
@ -306,6 +313,15 @@ void ObPlanCacheManager::ObPlanCacheEliminationTask::runTimerTask()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ObPlanCacheManager::ObPlanCacheEliminationTask::run_auto_flush_plan_cache_task()
|
||||||
|
{
|
||||||
|
if (OB_ISNULL(plan_cache_manager_)) {
|
||||||
|
// do nothing
|
||||||
|
} else {
|
||||||
|
IGNORE_RETURN plan_cache_manager_->flush_all_plan_cache();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ObPlanCacheManager::ObPlanCacheEliminationTask::run_plan_cache_task()
|
void ObPlanCacheManager::ObPlanCacheEliminationTask::run_plan_cache_task()
|
||||||
{
|
{
|
||||||
int ret = OB_SUCCESS;
|
int ret = OB_SUCCESS;
|
||||||
|
|||||||
@ -47,6 +47,7 @@ public:
|
|||||||
void run_plan_cache_task();
|
void run_plan_cache_task();
|
||||||
void run_ps_cache_task();
|
void run_ps_cache_task();
|
||||||
void run_free_cache_obj_task();
|
void run_free_cache_obj_task();
|
||||||
|
void run_auto_flush_plan_cache_task();
|
||||||
public:
|
public:
|
||||||
ObPlanCacheManager *plan_cache_manager_;
|
ObPlanCacheManager *plan_cache_manager_;
|
||||||
int64_t run_task_counter_;
|
int64_t run_task_counter_;
|
||||||
|
|||||||
@ -271,6 +271,7 @@ _ob_enable_prepared_statement
|
|||||||
_ob_get_gts_ahead_interval
|
_ob_get_gts_ahead_interval
|
||||||
_ob_max_thread_num
|
_ob_max_thread_num
|
||||||
_ob_obj_dep_maint_task_interval
|
_ob_obj_dep_maint_task_interval
|
||||||
|
_ob_plan_cache_auto_flush_interval
|
||||||
_ob_plan_cache_gc_strategy
|
_ob_plan_cache_gc_strategy
|
||||||
_ob_query_rate_limit
|
_ob_query_rate_limit
|
||||||
_ob_ssl_invited_nodes
|
_ob_ssl_invited_nodes
|
||||||
|
|||||||
Reference in New Issue
Block a user