alloc memory for every operator in ENABLE_DEBUG_LOG mode to trace close && destroy
This commit is contained in:
committed by
ob-robot
parent
5cee718006
commit
1866ba4ce3
@ -528,6 +528,10 @@ ObOperator::ObOperator(ObExecContext &exec_ctx, const ObOpSpec &spec, ObOpInput
|
||||
batch_reach_end_(false),
|
||||
row_reach_end_(false),
|
||||
output_batches_b4_rescan_(0),
|
||||
#ifdef ENABLE_DEBUG_LOG
|
||||
dummy_mem_context_(nullptr),
|
||||
dummy_ptr_(nullptr),
|
||||
#endif
|
||||
check_stack_overflow_(false)
|
||||
{
|
||||
eval_ctx_.max_batch_size_ = spec.max_batch_size_;
|
||||
@ -695,7 +699,17 @@ int ObOperator::open()
|
||||
LOG_WARN("init evaluate flags failed", K(ret));
|
||||
} else if (OB_FAIL(init_skip_vector())) {
|
||||
LOG_WARN("init skip vector failed", K(ret));
|
||||
} else if (OB_FAIL(inner_open())) {
|
||||
}
|
||||
#ifdef ENABLE_DEBUG_LOG
|
||||
else if (OB_FAIL(init_dummy_mem_context(ctx_.get_my_session()->get_effective_tenant_id()))) {
|
||||
LOG_WARN("failed to get mem context", K(ret));
|
||||
} else if (OB_LIKELY(nullptr == dummy_ptr_)
|
||||
&& OB_ISNULL(dummy_ptr_ = static_cast<char *>(dummy_mem_context_->get_malloc_allocator().alloc(sizeof(char))))) {
|
||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||
LOG_WARN("failed to alloc memory", K(ret));
|
||||
}
|
||||
#endif
|
||||
else if (OB_FAIL(inner_open())) {
|
||||
if (OB_TRY_LOCK_ROW_CONFLICT != ret && OB_TRANSACTION_SET_VIOLATION != ret) {
|
||||
LOG_WARN("Open this operator failed", K(ret), "op_type", op_name());
|
||||
}
|
||||
@ -955,6 +969,14 @@ int ObOperator::close()
|
||||
}
|
||||
IGNORE_RETURN submit_op_monitor_node();
|
||||
IGNORE_RETURN setup_op_feedback_info();
|
||||
#ifdef ENABLE_DEBUG_LOG
|
||||
if (nullptr != dummy_mem_context_) {
|
||||
if (nullptr != dummy_ptr_) {
|
||||
dummy_mem_context_->get_malloc_allocator().free(dummy_ptr_);
|
||||
dummy_ptr_ = nullptr;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@ -1446,6 +1468,25 @@ inline int ObOperator::get_next_row_vectorizely()
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_DEBUG_LOG
|
||||
inline int ObOperator::init_dummy_mem_context(uint64_t tenant_id)
|
||||
{
|
||||
int ret = common::OB_SUCCESS;
|
||||
if (OB_LIKELY(NULL == dummy_mem_context_)) {
|
||||
lib::ContextParam param;
|
||||
param.set_properties(lib::USE_TL_PAGE_OPTIONAL)
|
||||
.set_mem_attr(tenant_id, "ObSqlOp",
|
||||
common::ObCtxIds::DEFAULT_CTX_ID);
|
||||
if (OB_FAIL(CURRENT_CONTEXT->CREATE_CONTEXT(dummy_mem_context_, param))) {
|
||||
SQL_ENG_LOG(WARN, "create entity failed", K(ret));
|
||||
} else if (OB_ISNULL(dummy_mem_context_)) {
|
||||
SQL_ENG_LOG(WARN, "mem entity is null", K(ret));
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
int ObBatchRowIter::get_next_row()
|
||||
{
|
||||
const int64_t max_row_cnt = INT64_MAX;
|
||||
|
||||
@ -638,12 +638,23 @@ protected:
|
||||
common::ObActiveSessionGuard::get_stat().plan_line_id_ = -1;
|
||||
}
|
||||
}
|
||||
#ifdef ENABLE_DEBUG_LOG
|
||||
inline int init_dummy_mem_context(uint64_t tenant_id);
|
||||
#endif
|
||||
uint64_t cpu_begin_time_; // start of counting cpu time
|
||||
uint64_t total_time_; // total time cost on this op, including io & cpu time
|
||||
protected:
|
||||
bool batch_reach_end_;
|
||||
bool row_reach_end_;
|
||||
int64_t output_batches_b4_rescan_;
|
||||
//The following two variables are used to track whether the operator
|
||||
//has been closed && destroyed in test mode. We apply for a small
|
||||
//memory for each operator in open. If there is
|
||||
//no close, mem_context will release it and give an alarm
|
||||
#ifdef ENABLE_DEBUG_LOG
|
||||
lib::MemoryContext dummy_mem_context_;
|
||||
char *dummy_ptr_;
|
||||
#endif
|
||||
bool check_stack_overflow_;
|
||||
DISALLOW_COPY_AND_ASSIGN(ObOperator);
|
||||
};
|
||||
@ -698,6 +709,12 @@ int ObOpSpec::find_target_specs(T &spec, const FILTER &f, common::ObIArray<T *>
|
||||
|
||||
inline void ObOperator::destroy()
|
||||
{
|
||||
#ifdef ENABLE_DEBUG_LOG
|
||||
if (OB_LIKELY(nullptr != dummy_mem_context_)) {
|
||||
DESTROY_CONTEXT(dummy_mem_context_);
|
||||
dummy_mem_context_ = nullptr;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
OB_INLINE void ObOperator::clear_evaluated_flag()
|
||||
|
||||
Reference in New Issue
Block a user