[DeadLock] fix detector bug

This commit is contained in:
obdev
2023-02-20 12:47:38 +00:00
committed by ob-robot
parent 2e954397ec
commit b1faf451eb
13 changed files with 428 additions and 86 deletions

View File

@ -407,13 +407,18 @@ int ObSqlTransControl::do_end_trans_(ObSQLSessionInfo *session,
{
int ret = OB_SUCCESS;
transaction::ObTxDesc *&tx_ptr = session->get_tx_desc();
if (session->is_registered_to_deadlock()) {
if (OB_SUCC(MTL(share::detector::ObDeadLockDetectorMgr*)->unregister_key(tx_ptr->tid()))) {
DETECT_LOG(INFO, "unregister deadlock detector in do end trans", KPC(tx_ptr));
} else {
DETECT_LOG(WARN, "unregister deadlock detector in do end trans failed", KPC(tx_ptr));
}
session->set_registered_to_deadlock(false);
bool is_detector_exist = false;
int tmp_ret = OB_SUCCESS;
if (OB_ISNULL(MTL(share::detector::ObDeadLockDetectorMgr*))) {
tmp_ret = OB_BAD_NULL_ERROR;
DETECT_LOG(WARN, "MTL ObDeadLockDetectorMgr is NULL", K(tmp_ret), K(tx_ptr->tid()));
} else if (OB_TMP_FAIL(MTL(share::detector::ObDeadLockDetectorMgr*)->
check_detector_exist(tx_ptr->tid(), is_detector_exist))) {
DETECT_LOG(WARN, "fail to check detector exist, may causing detector leak", K(tmp_ret),
K(tx_ptr->tid()));
} else if (is_detector_exist) {
ObTransDeadlockDetectorAdapter::unregister_from_deadlock_detector(tx_ptr->tid(),
ObTransDeadlockDetectorAdapter::UnregisterPath::DO_END_TRANS);
}
if (session->associated_xa() && !is_explicit) {
ret = OB_TRANS_XA_RMFAIL;

View File

@ -169,7 +169,6 @@ ObSQLSessionInfo::ObSQLSessionInfo() :
is_table_name_hidden_(false),
piece_cache_(NULL),
is_load_data_exec_session_(false),
is_registered_to_deadlock_(false),
pl_exact_err_msg_(),
is_ps_prepare_stage_(false),
got_conn_res_(false),
@ -197,7 +196,6 @@ int ObSQLSessionInfo::init(uint32_t sessid, uint64_t proxy_sessid,
UNUSED(tenant_id);
int ret = OB_SUCCESS;
static const int64_t PS_BUCKET_NUM = 64;
set_registered_to_deadlock(false);
if (OB_FAIL(ObBasicSessionInfo::init(sessid, proxy_sessid, bucket_allocator, tz_info))) {
LOG_WARN("fail to init basic session info", K(ret));
} else if (!is_acquire_from_pool() &&
@ -325,7 +323,6 @@ void ObSQLSessionInfo::reset(bool skip_sys_var)
prelock_ = false;
proxy_version_ = 0;
min_proxy_version_ps_ = 0;
set_registered_to_deadlock(false);
if (OB_NOT_NULL(mem_context_)) {
destroy_contexts_map(contexts_map_, mem_context_->get_malloc_allocator());
DESTROY_CONTEXT(mem_context_);

View File

@ -963,8 +963,6 @@ public:
cached_tenant_config_info_.refresh();
return cached_tenant_config_info_.get_enable_sql_extension();
}
bool is_registered_to_deadlock() const { return ATOMIC_LOAD(&is_registered_to_deadlock_); }
void set_registered_to_deadlock(bool state) { ATOMIC_SET(&is_registered_to_deadlock_, state); }
bool is_ps_prepare_stage() const { return is_ps_prepare_stage_; }
void set_is_ps_prepare_stage(bool v) { is_ps_prepare_stage_ = v; }
int get_tenant_audit_trail_type(ObAuditTrailType &at_type)
@ -1139,8 +1137,6 @@ private:
bool is_table_name_hidden_;
void *piece_cache_;
bool is_load_data_exec_session_;
// 记录session是否注册过死锁检测的信息
bool is_registered_to_deadlock_;
ObSqlString pl_exact_err_msg_;
bool is_ps_prepare_stage_;
// Record whether this session has got connection resource, which means it increased connections count.