fix plan cache memleak and switch invalid tenant

This commit is contained in:
obdev 2023-05-16 02:41:26 +00:00 committed by ob-robot
parent 406639266a
commit c0e1905a6c
2 changed files with 17 additions and 7 deletions

View File

@ -325,7 +325,11 @@ int ObAllPlanCacheStatI1::get_all_tenant_ids(ObIArray<uint64_t> &tenant_ids)
for (int64_t i = 0; OB_SUCC(ret) && i < tenant_ids_.count(); i++) {
// to keep the save interface
ret = tenant_ids.push_back(tenant_ids_.at(i));
if (common::OB_INVALID_TENANT_ID == tenant_ids_.at(i)) {
// skip
} else {
ret = tenant_ids.push_back(tenant_ids_.at(i));
}
}
return ret;
}
@ -334,7 +338,10 @@ int ObAllPlanCacheStat::get_all_tenant_ids(ObIArray<uint64_t> &tenant_ids)
{
int ret = OB_SUCCESS;
// sys tenant show all tenant plan cache stat
if (is_sys_tenant(effective_tenant_id_)) {
if (common::OB_INVALID_TENANT_ID == effective_tenant_id_) {
ret = OB_ERR_UNEXPECTED;
SERVER_LOG(WARN, "invalid effective_tenant_id_", KR(ret), K(effective_tenant_id_));
} else if (is_sys_tenant(effective_tenant_id_)) {
if (OB_FAIL(GCTX.omt_->get_mtl_tenant_ids(tenant_id_array_))) {
SERVER_LOG(WARN, "failed to add tenant id", K(ret));
}

View File

@ -48,12 +48,15 @@ int ObCacheObjectFactory::alloc(ObCacheObjGuard& guard, ObLibCacheNameSpace ns,
void ObCacheObjectFactory::inner_free(ObILibCacheObject *&cache_obj,
const CacheRefHandleID ref_handle)
{
int ret = OB_SUCCESS;
uint64_t tenant_id = cache_obj->get_tenant_id();
ObPlanCache *lib_cache = MTL(ObPlanCache*);
if (OB_ISNULL(lib_cache)) {
LOG_WARN_RET(OB_ERR_UNEXPECTED, "invalid null plan cache");
} else {
lib_cache->free_cache_obj(cache_obj, ref_handle);
MTL_SWITCH(tenant_id) {
ObPlanCache *lib_cache = MTL(ObPlanCache*);
if (OB_ISNULL(lib_cache)) {
LOG_WARN_RET(OB_ERR_UNEXPECTED, "invalid null plan cache");
} else {
lib_cache->free_cache_obj(cache_obj, ref_handle);
}
}
}