[CP] [master] deadlock between memctx and partctx

This commit is contained in:
chinaxing
2023-08-01 17:24:27 +00:00
committed by ob-robot
parent a56c5b6dec
commit 0a387f044b
2 changed files with 20 additions and 30 deletions

View File

@ -769,8 +769,7 @@ int ObTransService::register_mds_into_tx(ObTxDesc &tx_desc,
time_guard.click("register in ctx begin"); time_guard.click("register in ctx begin");
do { do {
if (OB_FAIL(register_mds_into_ctx(*(arg.tx_desc_), ls_id, type, buf, buf_len, if (OB_FAIL(register_mds_into_ctx_(*(arg.tx_desc_), ls_id, type, buf, buf_len, register_flag))) {
register_flag))) {
TRANS_LOG(WARN, "register msd into ctx failed", K(ret)); TRANS_LOG(WARN, "register msd into ctx failed", K(ret));
if (OB_EAGAIN == ret) { if (OB_EAGAIN == ret) {
if (ObTimeUtil::current_time() >= tx_desc.expire_ts_) { if (ObTimeUtil::current_time() >= tx_desc.expire_ts_) {
@ -857,7 +856,7 @@ int ObTransService::register_mds_into_tx(ObTxDesc &tx_desc,
return ret; return ret;
} }
int ObTransService::register_mds_into_ctx(ObTxDesc &tx_desc, int ObTransService::register_mds_into_ctx_(ObTxDesc &tx_desc,
const ObLSID &ls_id, const ObLSID &ls_id,
const ObTxDataSourceType &type, const ObTxDataSourceType &type,
const char *buf, const char *buf,
@ -876,23 +875,14 @@ int ObTransService::register_mds_into_ctx(ObTxDesc &tx_desc,
} else if (FALSE_IT(store_ctx.ls_id_ = ls_id)) { } else if (FALSE_IT(store_ctx.ls_id_ = ls_id)) {
} else if (OB_FAIL(get_write_store_ctx(tx_desc, snapshot, write_flag, store_ctx, true))) { } else if (OB_FAIL(get_write_store_ctx(tx_desc, snapshot, write_flag, store_ctx, true))) {
TRANS_LOG(WARN, "get store ctx failed", KR(ret), K(tx_desc), K(ls_id)); TRANS_LOG(WARN, "get store ctx failed", KR(ret), K(tx_desc), K(ls_id));
} else {
do {
memtable::ObMvccWriteGuard guard;
if (OB_FAIL(guard.write_auth(store_ctx))) {
TRANS_LOG(WARN, "write auth failed", KR(ret), K(tx_desc), K(ls_id));
} else { } else {
ObPartTransCtx *ctx = store_ctx.mvcc_acc_ctx_.tx_ctx_; ObPartTransCtx *ctx = store_ctx.mvcc_acc_ctx_.tx_ctx_;
if (OB_ISNULL(ctx)) { if (OB_ISNULL(ctx)) {
ret = OB_ERR_UNEXPECTED; ret = OB_ERR_UNEXPECTED;
TRANS_LOG(WARN, "unexpected null ptr", KR(ret), K(tx_desc), K(ls_id), K(type)); TRANS_LOG(WARN, "unexpected null ptr", KR(ret), K(tx_desc), K(ls_id), K(type));
} else if (OB_FAIL(ctx->register_multi_data_source( } else if (OB_FAIL(ctx->register_multi_data_source(type, buf, buf_len, false /*try lock*/, register_flag))) {
type, buf, buf_len, false /* try lock */, register_flag))) { TRANS_LOG(WARN, "register multi source data failed", KR(ret), K(tx_desc), K(ls_id), K(type), K(register_flag));
TRANS_LOG(WARN, "register multi source data failed", KR(ret), K(tx_desc), K(ls_id),
K(type));
} }
}
} while (0);
int tmp_ret = OB_SUCCESS; int tmp_ret = OB_SUCCESS;
if (OB_SUCCESS != (tmp_ret = revert_store_ctx(store_ctx))) { if (OB_SUCCESS != (tmp_ret = revert_store_ctx(store_ctx))) {
TRANS_LOG(WARN, "revert store ctx failed", KR(tmp_ret), K(tx_desc), K(ls_id), K(type)); TRANS_LOG(WARN, "revert store ctx failed", KR(tmp_ret), K(tx_desc), K(ls_id), K(type));

View File

@ -202,12 +202,6 @@ public:
const int64_t buf_len, const int64_t buf_len,
const int64_t request_id = 0, const int64_t request_id = 0,
const ObRegisterMdsFlag &register_flag = ObRegisterMdsFlag()); const ObRegisterMdsFlag &register_flag = ObRegisterMdsFlag());
int register_mds_into_ctx(ObTxDesc &tx_desc,
const share::ObLSID &ls_id,
const ObTxDataSourceType &type,
const char *buf,
const int64_t buf_len,
const ObRegisterMdsFlag &register_flag);
ObTxELRUtil &get_tx_elr_util() { return elr_util_; } ObTxELRUtil &get_tx_elr_util() { return elr_util_; }
#ifdef ENABLE_DEBUG_LOG #ifdef ENABLE_DEBUG_LOG
transaction::ObDefensiveCheckMgr *get_defensive_check_mgr() { return defensive_check_mgr_; } transaction::ObDefensiveCheckMgr *get_defensive_check_mgr() { return defensive_check_mgr_; }
@ -215,6 +209,12 @@ public:
private: private:
void check_env_(); void check_env_();
bool can_create_ctx_(const int64_t trx_start_ts, const common::ObTsWindows &changing_leader_windows); bool can_create_ctx_(const int64_t trx_start_ts, const common::ObTsWindows &changing_leader_windows);
int register_mds_into_ctx_(ObTxDesc &tx_desc,
const share::ObLSID &ls_id,
const ObTxDataSourceType &type,
const char *buf,
const int64_t buf_len,
const ObRegisterMdsFlag &register_flag);
private: private:
int handle_redo_sync_task_(ObDupTableRedoSyncTask *task, bool &need_release_task); int handle_redo_sync_task_(ObDupTableRedoSyncTask *task, bool &need_release_task);
int handle_dup_pre_commit_task_(ObPreCommitTask *task, bool &need_release_task); int handle_dup_pre_commit_task_(ObPreCommitTask *task, bool &need_release_task);