Adjust the way automatic memory management records some variables to avoid cross-thread access
This commit is contained in:
parent
0a9f1e0c4f
commit
02d683674d
@ -43,7 +43,12 @@ int ObSqlMemMgrProcessor::init(
|
||||
LOG_WARN("unexpected cache size got", K(lbt()), K(cache_size), K(op_id), K(op_type));
|
||||
cache_size = DEFAULT_CACHE_SIZE;
|
||||
}
|
||||
if (OB_FAIL(alloc_dir_id(dir_id_))) {
|
||||
if (OB_ISNULL(exec_ctx)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("failed to get exec ctx", K(ret));
|
||||
} else if (OB_FAIL(profile_.set_exec_info(*exec_ctx))) {
|
||||
LOG_WARN("failed to set exec info", K(ret));
|
||||
} else if (OB_FAIL(alloc_dir_id(dir_id_))) {
|
||||
} else if (OB_NOT_NULL(sql_mem_mgr)) {
|
||||
if (sql_mem_mgr->enable_auto_memory_mgr()) {
|
||||
tmp_enable_auto_mem_mgr = true;
|
||||
|
@ -43,49 +43,45 @@ const int64_t ObSqlWorkAreaProfile::MIN_BOUND_SIZE[ObSqlWorkAreaType::MAX_TYPE]
|
||||
|
||||
int64_t ObSqlWorkAreaProfile::get_dop()
|
||||
{
|
||||
int64_t dop = 1;
|
||||
if (OB_NOT_NULL(exec_ctx_)) {
|
||||
dop = ObPxSqcUtil::get_actual_worker_count(exec_ctx_);
|
||||
}
|
||||
return dop;
|
||||
return dop_;
|
||||
}
|
||||
|
||||
uint64_t ObSqlWorkAreaProfile::get_plan_id()
|
||||
{
|
||||
uint64_t plan_id = UINT64_MAX;
|
||||
if (OB_NOT_NULL(exec_ctx_)) {
|
||||
plan_id = ObPxSqcUtil::get_plan_id(exec_ctx_);
|
||||
}
|
||||
return plan_id;
|
||||
return plan_id_;
|
||||
}
|
||||
|
||||
uint64_t ObSqlWorkAreaProfile::get_exec_id()
|
||||
{
|
||||
uint64_t exec_id = UINT64_MAX;
|
||||
if (OB_NOT_NULL(exec_ctx_)) {
|
||||
exec_id = ObPxSqcUtil::get_exec_id(exec_ctx_);
|
||||
}
|
||||
return exec_id;
|
||||
return exec_id_;
|
||||
}
|
||||
|
||||
const char* ObSqlWorkAreaProfile::get_sql_id()
|
||||
{
|
||||
const char* sql_id = nullptr;
|
||||
if (OB_NOT_NULL(exec_ctx_)) {
|
||||
sql_id = ObPxSqcUtil::get_sql_id(exec_ctx_);
|
||||
}
|
||||
return sql_id;
|
||||
return sql_id_.ptr();
|
||||
}
|
||||
|
||||
uint64_t ObSqlWorkAreaProfile::get_session_id()
|
||||
{
|
||||
uint64_t session_id = UINT64_MAX;
|
||||
if (OB_NOT_NULL(exec_ctx_)) {
|
||||
session_id = ObPxSqcUtil::get_session_id(exec_ctx_);
|
||||
}
|
||||
return session_id;
|
||||
return session_id_;
|
||||
}
|
||||
|
||||
int ObSqlWorkAreaProfile::set_exec_info(ObExecContext &exec_ctx)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
dop_ = ObPxSqcUtil::get_actual_worker_count(&exec_ctx);
|
||||
plan_id_ = ObPxSqcUtil::get_plan_id(&exec_ctx);
|
||||
exec_id_ = ObPxSqcUtil::get_exec_id(&exec_ctx);
|
||||
session_id_ = ObPxSqcUtil::get_session_id(&exec_ctx);
|
||||
ObPhysicalPlanCtx *plan_ctx = exec_ctx.get_physical_plan_ctx();
|
||||
if (OB_NOT_NULL(plan_ctx) && OB_NOT_NULL(plan_ctx->get_phy_plan())) {
|
||||
OZ (ob_write_string(exec_ctx.get_allocator(),
|
||||
plan_ctx->get_phy_plan()->get_sql_id_string(),
|
||||
sql_id_));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
int ObSqlWorkAreaIntervalStat::analyze_profile(
|
||||
ObSqlWorkAreaProfile &profile,
|
||||
|
@ -39,7 +39,8 @@ public:
|
||||
random_id_(0), type_(type), op_type_(PHY_INVALID), op_id_(UINT64_MAX), exec_ctx_(nullptr),
|
||||
min_size_(0), row_count_(0), input_size_(0), bucket_size_(0),
|
||||
chunk_size_(0), cache_size_(-1), one_pass_size_(0), expect_size_(OB_INVALID_ID),
|
||||
global_bound_size_(INT64_MAX), max_bound_(INT64_MAX), delta_size_(0), data_size_(0),
|
||||
global_bound_size_(INT64_MAX), dop_(-1), plan_id_(-1), exec_id_(-1), sql_id_(),
|
||||
session_id_(-1), max_bound_(INT64_MAX), delta_size_(0), data_size_(0),
|
||||
max_mem_used_(0), mem_used_(0),
|
||||
pre_mem_used_(0), dumped_size_(0), data_ratio_(0.5), active_time_(0), number_pass_(0),
|
||||
calc_count_(0)
|
||||
@ -66,6 +67,7 @@ public:
|
||||
bucket_size_ = bucket_size;
|
||||
}
|
||||
|
||||
int set_exec_info(ObExecContext &exec_ctx);
|
||||
OB_INLINE void set_operator_type(ObPhyOperatorType op_type) { op_type_ = op_type; }
|
||||
OB_INLINE void set_operator_id(uint64_t op_id) { op_id_ = op_id; }
|
||||
OB_INLINE void set_exec_ctx(ObExecContext *exec_ctx) { exec_ctx_ = exec_ctx; }
|
||||
@ -173,6 +175,11 @@ private:
|
||||
int64_t one_pass_size_;
|
||||
int64_t expect_size_;
|
||||
int64_t global_bound_size_;
|
||||
int64_t dop_;
|
||||
int64_t plan_id_;
|
||||
int64_t exec_id_;
|
||||
ObString sql_id_;
|
||||
int64_t session_id_;
|
||||
// 取 min(cache_size, global_bound_size)
|
||||
// sort场景,在global_bound_size比较大情况下,sort理论上有data和extra内存,data应该是one-pass size
|
||||
// 也就是expect_size
|
||||
|
Loading…
x
Reference in New Issue
Block a user