fix memory leak when unit migrate or del tenant happens
This commit is contained in:
parent
85d7d1e6f8
commit
9d77e24a32
@ -415,6 +415,9 @@ int ObMultiTenant::add_tenant(const uint64_t tenant_id, const double min_cpu, co
|
||||
OB_FAIL(OTC_MGR.got_version(tenant_id, common::ObSystemConfig::INIT_VERSION))) {
|
||||
LOG_ERROR("failed to got version", K(tenant_id), K(ret));
|
||||
#endif
|
||||
} else if (OB_FAIL(GCTX.sql_engine_->get_plan_cache_manager()->validate_plan_cache(tenant_id))) {
|
||||
// do nothing
|
||||
LOG_WARN("failed to active plan cache", K(ret), K(tenant_id));
|
||||
} else {
|
||||
LOG_INFO("activate tenant done", K(tenant_id), K(ret));
|
||||
}
|
||||
|
@ -334,6 +334,8 @@ int ObAllPlanCacheStat::get_row_from_tenants()
|
||||
ObPlanCache* plan_cache = pcm_->get_plan_cache(tenant_id);
|
||||
if (OB_UNLIKELY(NULL == plan_cache)) {
|
||||
SERVER_LOG(WARN, "invalid plan cache", K(ret), K(tenant_id));
|
||||
} else if (!plan_cache->is_valid()) {
|
||||
// do nothing
|
||||
} else {
|
||||
if (OB_FAIL(fill_cells(*plan_cache))) {
|
||||
SERVER_LOG(WARN, "fail to fill cells", K(ret), K(cur_row_));
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/**
|
||||
* Copyright (c) 2021 OceanBase
|
||||
* OceanBase CE is licensed under Mulan PubL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PubL v2.
|
||||
|
@ -106,7 +106,9 @@ int ObCacheObjectFactory::alloc(
|
||||
* then the atomicity of hashmap can ensure that only one thread does the removal action, and
|
||||
* only this thread gets the CacheObject pointer to do subsequent destructuring
|
||||
*/
|
||||
if (OB_FAIL(plan_cache->get_deleted_map().set_refactored(cache_obj_id, cache_obj))) {
|
||||
if (!plan_cache->is_valid()) {
|
||||
// do nothing
|
||||
} else if (OB_FAIL(plan_cache->get_deleted_map().set_refactored(cache_obj_id, cache_obj))) {
|
||||
LOG_WARN("failed to add element to hashmap", K(ret));
|
||||
inner_free(cache_obj);
|
||||
cache_obj = NULL;
|
||||
|
@ -1080,7 +1080,9 @@ void ObPlanCache::dec_ref_count()
|
||||
if (ref_count > 0) {
|
||||
} else if (0 == ref_count) {
|
||||
// delete
|
||||
this->~ObPlanCache();
|
||||
this->set_valid(false);
|
||||
destroy();
|
||||
// this->~ObPlanCache();
|
||||
} else if (ref_count < 0) {
|
||||
BACKTRACE(ERROR, true, "Plan Cache %p ref count < 0, ref_count = %ld", this, ref_count);
|
||||
}
|
||||
|
@ -109,6 +109,20 @@ ObPsCache* ObPlanCacheManager::get_ps_cache(const uint64_t tenant_id)
|
||||
return ps_cache;
|
||||
}
|
||||
|
||||
int ObPlanCacheManager::validate_plan_cache(const uint64_t& tenant_id)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
|
||||
ObPlanCache* plan_cache = get_plan_cache(tenant_id);
|
||||
if (OB_ISNULL(plan_cache)) {
|
||||
// do nothing, and others will create this later.
|
||||
} else {
|
||||
plan_cache->set_valid(true);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
// maybe get plan_cache = NULL;
|
||||
// this thread other thread
|
||||
//
|
||||
@ -251,7 +265,7 @@ int ObPlanCacheManager::revert_plan_cache(const uint64_t& tenant_id)
|
||||
int ret = OB_SUCCESS;
|
||||
ObPlanCache* ppc = NULL;
|
||||
observer::ObReqTimeGuard req_timeinfo_guard;
|
||||
int tmp_ret = pcm_.erase_refactored(tenant_id, &ppc);
|
||||
int tmp_ret = pcm_.get_refactored(tenant_id, ppc);
|
||||
if (OB_SUCCESS == tmp_ret && NULL != ppc) {
|
||||
SQL_PC_LOG(INFO, "plan_cache_manager revert plan cache", "pc ref_count", ppc->get_ref_count(), K(tenant_id));
|
||||
// cancel scheduled task
|
||||
|
@ -82,6 +82,7 @@ public:
|
||||
ObPlanCache* get_or_create_plan_cache(uint64_t tenant_id, const ObPCMemPctConf& pc_mem_conf);
|
||||
ObPsCache* get_or_create_ps_cache(const uint64_t tenant_id, const ObPCMemPctConf& pc_mem_conf);
|
||||
|
||||
int validate_plan_cache(const uint64_t& tenant_id);
|
||||
int revert_plan_cache(const uint64_t& tenant_id);
|
||||
int revert_ps_cache(const uint64_t& tenant_id);
|
||||
int flush_all_plan_cache();
|
||||
|
@ -611,7 +611,7 @@ void ObSQLSessionInfo::get_session_priv_info(share::schema::ObSessionPrivInfo& s
|
||||
ObPlanCache* ObSQLSessionInfo::get_plan_cache()
|
||||
{
|
||||
if (OB_LIKELY(NULL != plan_cache_manager_)) {
|
||||
if (OB_NOT_NULL(plan_cache_) && plan_cache_->is_valid()) {
|
||||
if (OB_NOT_NULL(plan_cache_)) {
|
||||
// do nothing
|
||||
} else {
|
||||
// release old plancache and get new
|
||||
|
Loading…
x
Reference in New Issue
Block a user