fix memory leak caused by ObSolidifiedVarsContext::local_tz_wrap_

This commit is contained in:
JinmaoLi
2024-05-24 12:02:07 +00:00
committed by ob-robot
parent 38c42c63d0
commit c7a7805e27
5 changed files with 12 additions and 31 deletions

View File

@ -766,33 +766,6 @@ int ObSolidifiedVarsContext::get_local_tz_info(const sql::ObBasicSessionInfo *se
return ret;
}
OB_DEF_SERIALIZE(ObSolidifiedVarsContext)
{
int ret = OB_SUCCESS;
if (NULL != local_session_var_) {
OB_UNIS_ENCODE(*local_session_var_);
}
return ret;
}
OB_DEF_SERIALIZE_SIZE(ObSolidifiedVarsContext)
{
int64_t len = 0;
if (NULL != local_session_var_) {
OB_UNIS_ADD_LEN(*local_session_var_);
}
return len;
}
OB_DEF_DESERIALIZE(ObSolidifiedVarsContext)
{
int ret = OB_SUCCESS;
if (NULL != local_session_var_) {
OB_UNIS_DECODE(*local_session_var_);
}
return ret;
}
DEF_TO_STRING(ObSolidifiedVarsContext)
{
int64_t pos = 0;

View File

@ -228,7 +228,6 @@ int calc_##tritype##_expr(const ObExpr &expr, ObEvalCtx &ctx, \
class ObSolidifiedVarsContext
{
OB_UNIS_VERSION(1);
public:
ObSolidifiedVarsContext() :
local_session_var_(NULL),
@ -242,8 +241,10 @@ public:
local_tz_wrap_(NULL)
{
}
virtual ~ObSolidifiedVarsContext() {
virtual ~ObSolidifiedVarsContext()
{
if (NULL != local_tz_wrap_ && NULL != alloc_) {
local_tz_wrap_->~ObTimeZoneInfoWrap();
alloc_->free(local_tz_wrap_);
local_tz_wrap_ = NULL;
}

View File

@ -146,7 +146,7 @@ ObExecContext::~ObExecContext()
phy_plan_ctx_->~ObPhysicalPlanCtx();
} else {
// free subschema map memory
phy_plan_ctx_->get_subschema_ctx().destroy();
phy_plan_ctx_->destroy();
}
}
phy_plan_ctx_ = NULL;

View File

@ -129,7 +129,7 @@ ObPhysicalPlanCtx::ObPhysicalPlanCtx(common::ObIAllocator &allocator)
ObPhysicalPlanCtx::~ObPhysicalPlanCtx()
{
subschema_ctx_.destroy();
destroy();
}
void ObPhysicalPlanCtx::restore_param_store(const int64_t original_param_cnt)

View File

@ -97,6 +97,13 @@ class ObPhysicalPlanCtx
public:
explicit ObPhysicalPlanCtx(common::ObIAllocator &allocator);
virtual ~ObPhysicalPlanCtx();
void destroy()
{
// Member variables that need to request additional memory
// with another allocator should call destroy here.
subschema_ctx_.destroy();
all_local_session_vars_.destroy();
}
inline void set_tenant_id(uint64_t tenant_id) { tenant_id_ = tenant_id; }
inline void set_show_seed(bool show_seed) { is_show_seed_ = show_seed; }
inline uint64_t get_tenant_id() { return tenant_id_; }