add double-destroy check for MemoryContext
This commit is contained in:
@ -61,12 +61,12 @@ int ObCacheObjectFactory::alloc(
|
||||
mem_attr.label_ = ObNewModIds::OB_SQL_PHY_PLAN;
|
||||
}
|
||||
mem_attr.ctx_id_ = ObCtxIds::PLAN_CACHE_CTX_ID;
|
||||
MemoryContext* entity = NULL;
|
||||
MemoryContext entity = NULL;
|
||||
|
||||
if (OB_UNLIKELY(co_type < T_CO_SQL_CRSR) || OB_UNLIKELY(co_type >= T_CO_MAX) || OB_ISNULL(plan_cache)) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("co_type is invalid", K(co_type), K(plan_cache), K(tenant_id));
|
||||
} else if (OB_FAIL(ROOT_CONTEXT.CREATE_CONTEXT(entity, lib::ContextParam().set_mem_attr(mem_attr)))) {
|
||||
} else if (OB_FAIL(ROOT_CONTEXT->CREATE_CONTEXT(entity, lib::ContextParam().set_mem_attr(mem_attr)))) {
|
||||
LOG_WARN("create entity failed", K(ret), K(mem_attr));
|
||||
} else if (NULL == entity) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
@ -79,7 +79,7 @@ int ObCacheObjectFactory::alloc(
|
||||
switch (co_type) {
|
||||
case T_CO_SQL_CRSR:
|
||||
if (NULL != (buf = entity->get_arena_allocator().alloc(sizeof(ObPhysicalPlan)))) {
|
||||
cache_obj = new (buf) ObPhysicalPlan(*entity);
|
||||
cache_obj = new (buf) ObPhysicalPlan(entity);
|
||||
}
|
||||
break;
|
||||
case T_CO_ANON:
|
||||
@ -180,13 +180,13 @@ void ObCacheObjectFactory::inner_free(ObCacheObject* cache_obj)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
|
||||
MemoryContext& entity = cache_obj->get_mem_context();
|
||||
WITH_CONTEXT(&entity)
|
||||
MemoryContext entity = cache_obj->get_mem_context();
|
||||
WITH_CONTEXT(entity)
|
||||
{
|
||||
cache_obj->~ObCacheObject();
|
||||
}
|
||||
cache_obj = NULL;
|
||||
DESTROY_CONTEXT(&entity);
|
||||
DESTROY_CONTEXT(entity);
|
||||
}
|
||||
|
||||
ObPlanCache* ObCacheObjectFactory::get_plan_cache(const uint64_t tenant_id)
|
||||
|
||||
Reference in New Issue
Block a user