Support timing auto flush plan cache

This commit is contained in:
obdev
2022-11-18 13:05:43 +00:00
committed by wangzelin.wzl
parent d4c5eb91dc
commit 931a1810cc
4 changed files with 21 additions and 0 deletions

View File

@ -277,17 +277,24 @@ int ObPlanCacheManager::revert_plan_cache(const uint64_t &tenant_id)
void ObPlanCacheManager::ObPlanCacheEliminationTask::runTimerTask()
{
#define NEED_AUTO_FLUSH_PC(v) (0 == v ? false : true)
int ret = OB_SUCCESS;
if (OB_ISNULL(plan_cache_manager_)) {
ret = OB_NOT_INIT;
SQL_PC_LOG(WARN, "plan_cache_manager not inited", K(ret));
} 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
observer::ObReqTimeGuard req_timeinfo_guard;
run_plan_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",
"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()
{
int ret = OB_SUCCESS;

View File

@ -47,6 +47,7 @@ public:
void run_plan_cache_task();
void run_ps_cache_task();
void run_free_cache_obj_task();
void run_auto_flush_plan_cache_task();
public:
ObPlanCacheManager *plan_cache_manager_;
int64_t run_task_counter_;