[CP] [3_1_x] fix unsafe access part_ctx member in iter_trans_stat

This commit is contained in:
chinaxing
2022-06-21 10:57:18 +08:00
committed by wangzelin.wzl
parent 9c6da65efd
commit e146d5743b
2 changed files with 8 additions and 1 deletions

View File

@ -741,6 +741,7 @@ public:
// If the transaction has not completed in 600 seconds, print its trace log
part_ctx->print_trace_log();
}
/* _NOTICE_: must acquire part_ctx's lock when accessing member of imprimitive type */
if (OB_SUCCESS == tmp_ret) {
ObPartitionArray participants_arr(
common::ObModIds::OB_TRANS_PARTITION_ARRAY, common::OB_MALLOC_NORMAL_BLOCK_SIZE);

View File

@ -12146,7 +12146,13 @@ int64_t ObPartTransCtx::get_part_trans_action() const
if (ObPartTransAction::UNKNOWN == action) {
if (stmt_info_.get_sql_no() > 0) {
action = stmt_info_.is_task_match() ? ObPartTransAction::END_TASK : ObPartTransAction::START_TASK;
int ret = OB_SUCCESS;
if (OB_FAIL(lock_.try_lock())) {
TRANS_LOG(INFO, "lock fail to get part_trans_action", K(ret), K_(trans_id), K_(self), KP(this));
} else {
action = stmt_info_.is_task_match() ? ObPartTransAction::END_TASK : ObPartTransAction::START_TASK;
lock_.unlock();
}
}
}