add double-destroy check for MemoryContext

This commit is contained in:
jg0
2021-07-27 19:54:14 +08:00
committed by wangzelin.wzl
parent 91852f9b58
commit 0b7773c43f
86 changed files with 416 additions and 329 deletions

View File

@ -934,7 +934,7 @@ int ObHashDistinct::ObHashDistinctCtx::assign_sub_ctx(
ObModIds::OB_SQL_HASH_DIST,
ObCtxIds::WORK_AREA)
.set_properties(lib::USE_TL_PAGE_OPTIONAL);
if (OB_FAIL(CURRENT_CONTEXT.CREATE_CONTEXT(mem_context_, param))) {
if (OB_FAIL(CURRENT_CONTEXT->CREATE_CONTEXT(mem_context_, param))) {
LOG_WARN("fail to create entity", K(ret));
} else if (OB_ISNULL(mem_context_)) {
ret = OB_ERR_UNEXPECTED;
@ -1022,11 +1022,11 @@ int ObHashDistinct::init_op_ctx(ObExecContext& ctx) const
} else if (OB_FAIL(init_cur_row(*op_ctx, need_copy_row_for_compute()))) {
LOG_WARN("init current row failed", K(ret));
} else {
lib::MemoryContext* mem_context = nullptr;
lib::MemoryContext mem_context = nullptr;
lib::ContextParam param;
param.set_mem_attr(ctx.get_my_session()->get_effective_tenant_id(), ObModIds::OB_SQL_HASH_DIST, ObCtxIds::WORK_AREA)
.set_properties(lib::USE_TL_PAGE_OPTIONAL);
if (OB_FAIL(CURRENT_CONTEXT.CREATE_CONTEXT(mem_context, param))) {
if (OB_FAIL(CURRENT_CONTEXT->CREATE_CONTEXT(mem_context, param))) {
LOG_WARN("fail to create entity", K(ret));
} else if (OB_ISNULL(mem_context)) {
ret = OB_ERR_UNEXPECTED;

View File

@ -69,7 +69,7 @@ public:
cur_ = 0;
}
TO_STRING_KV(K_(nbuckets), K_(buf_cnt), K_(cur));
lib::MemoryContext* mem_context_;
lib::MemoryContext mem_context_;
using RowArray = common::ObSegmentArray<HashRow*, OB_MALLOC_BIG_BLOCK_SIZE, common::ModulePageAllocator>;
RowArray buckets_;
int64_t nbuckets_;
@ -174,7 +174,7 @@ public:
// bool it_in_mem_; //iterate rows in mem
HashTable* hash_tab_;
ObChunkRowStore* ha_row_store_;
lib::MemoryContext* mem_context_ = nullptr;
lib::MemoryContext mem_context_ = nullptr;
bool ha_is_full_;
bool bkt_created_;
bool child_finished_;

View File

@ -76,7 +76,7 @@ public:
param.set_mem_attr(exec_ctx_.get_my_session()->get_effective_tenant_id(),
ObModIds::OB_HASH_NODE_GROUP_ROWS,
ObCtxIds::WORK_AREA);
if (OB_FAIL(CURRENT_CONTEXT.CREATE_CONTEXT(mem_context_, param))) {
if (OB_FAIL(CURRENT_CONTEXT->CREATE_CONTEXT(mem_context_, param))) {
LOG_WARN("memory entity create failed", K(ret));
}
}
@ -147,7 +147,7 @@ private:
int64_t group_idx_;
// memory allocator for group by partitions
lib::MemoryContext* mem_context_;
lib::MemoryContext mem_context_;
ObDList<ObGbyPartition> all_parts_;
@ -566,7 +566,6 @@ int64_t ObHashGroupBy::detect_part_cnt(const int64_t rows, ObHashGroupByCtx& gby
K(gby_ctx.get_data_hold_size()),
K(gby_ctx.get_part_hold_size()),
K(rows),
K(gby_ctx.mem_context_),
K(availble_mem_size),
K(est_dump_size));
return part_cnt;

View File

@ -138,7 +138,7 @@ int ObHashGroupByOp::init_mem_context()
lib::ContextParam param;
param.set_mem_attr(
ctx_.get_my_session()->get_effective_tenant_id(), ObModIds::OB_HASH_NODE_GROUP_ROWS, ObCtxIds::WORK_AREA);
if (OB_FAIL(CURRENT_CONTEXT.CREATE_CONTEXT(mem_context_, param))) {
if (OB_FAIL(CURRENT_CONTEXT->CREATE_CONTEXT(mem_context_, param))) {
LOG_WARN("memory entity create failed", K(ret));
}
}
@ -519,7 +519,6 @@ int64_t ObHashGroupByOp::detect_part_cnt(const int64_t rows) const
K(get_aggr_hold_size()),
K(get_dump_part_hold_size()),
K(rows),
K(mem_context_),
K(availble_mem_size),
K(est_dump_size));
return part_cnt;

View File

@ -179,7 +179,7 @@ private:
int64_t curr_group_id_;
// memory allocator for group by partitions
lib::MemoryContext* mem_context_;
lib::MemoryContext mem_context_;
ObDList<DatumStoreLinkPartition> dumped_group_parts_;
ObChunkDatumStore group_store_;