From 9cbcd25e12b0cb2089d915c3aee5c11aed533795 Mon Sep 17 00:00:00 2001 From: obdev Date: Thu, 16 Mar 2023 11:11:04 +0000 Subject: [PATCH] [DeadLock] try process with deadlock bad case in remote sql --- src/storage/memtable/ob_lock_wait_mgr.cpp | 2 +- src/storage/tx/ob_trans_deadlock_adapter.cpp | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/storage/memtable/ob_lock_wait_mgr.cpp b/src/storage/memtable/ob_lock_wait_mgr.cpp index 91c268ec28..9feec90ab8 100644 --- a/src/storage/memtable/ob_lock_wait_mgr.cpp +++ b/src/storage/memtable/ob_lock_wait_mgr.cpp @@ -217,6 +217,7 @@ bool ObLockWaitMgr::post_process(bool need_retry, bool& need_wait) } if (need_retry) { if ((need_wait = node->need_wait())) { + TLOCAL_NEED_WAIT_IN_LOCK_WAIT_MGR = true; // FIXME(xuwang.txw):create detector in check_timeout process // below code must keep current order to fix concurrency bug // more info see https://yuque.antfin.com/ob/transaction/arlswh @@ -591,7 +592,6 @@ int ObLockWaitMgr::post_lock(const int tmp_ret, tx_id, holder_tx_id); node->set_need_wait(); - TLOCAL_NEED_WAIT_IN_LOCK_WAIT_MGR = true; } } } diff --git a/src/storage/tx/ob_trans_deadlock_adapter.cpp b/src/storage/tx/ob_trans_deadlock_adapter.cpp index abba534f5e..469eb2fdfc 100644 --- a/src/storage/tx/ob_trans_deadlock_adapter.cpp +++ b/src/storage/tx/ob_trans_deadlock_adapter.cpp @@ -642,28 +642,28 @@ int ObTransDeadlockDetectorAdapter::maintain_deadlock_info_when_end_stmt(sql::Ob DETECT_LOG(ERROR, "session is NULL", PRINT_WRAPPER); } else if (++step && session->is_inner()) { DETECT_LOG(INFO, "inner session no need register to deadlock", PRINT_WRAPPER); - } else if (++step && memtable::TLOCAL_NEED_WAIT_IN_LOCK_WAIT_MGR) { - DETECT_LOG(INFO, "thread local flag marked local execution, no need register to deadlock here", PRINT_WRAPPER); } else if (++step && OB_ISNULL(desc = session->get_tx_desc())) { ret = OB_BAD_NULL_ERROR; DETECT_LOG(ERROR, "desc in session is NULL", PRINT_WRAPPER); + } else if (++step && OB_FAIL(desc->fetch_conflict_txs(conflict_txs))) { + DETECT_LOG(WARN, "fail to get conflict txs from desc", PRINT_WRAPPER); } else if (++step && !desc->is_valid()) { DETECT_LOG(INFO, "invalid tx desc no need register to deadlock", PRINT_WRAPPER); } else if (++step && is_rollback) {// statment is failed, maybe will try again, check if need register to deadlock detector if (++step && session->get_query_timeout_ts() < ObClockGenerator::getCurrentTime()) { unregister_from_deadlock_detector(desc->tid(), UnregisterPath::END_STMT_TIMEOUT); DETECT_LOG(INFO, "query timeout, no need register to deadlock", PRINT_WRAPPER); - } else if (++step && OB_FAIL(desc->fetch_conflict_txs(conflict_txs))) { - DETECT_LOG(WARN, "fail to get conflict txs from desc", PRINT_WRAPPER); } else if (++step && conflict_txs.empty()) { unregister_from_deadlock_detector(desc->tid(), UnregisterPath::END_STMT_NO_CONFLICT); DETECT_LOG(INFO, "try unregister deadlock detecotr cause conflict array is empty", PRINT_WRAPPER); } else if (++step && exec_ctx.get_errcode() != OB_TRY_LOCK_ROW_CONFLICT) { unregister_from_deadlock_detector(desc->tid(), UnregisterPath::END_STMT_OTHER_ERR); DETECT_LOG(INFO, "try unregister deadlock detecotr cause meet non-lock error", PRINT_WRAPPER); + } else if (++step && memtable::TLOCAL_NEED_WAIT_IN_LOCK_WAIT_MGR) { + DETECT_LOG(INFO, "thread local flag marked local execution, no need register to deadlock here", PRINT_WRAPPER); } else if (++step && OB_FAIL(register_remote_execution_or_replace_conflict_trans_ids(desc->tid(), - session->get_sessid(), - conflict_txs))) { + session->get_sessid(), + conflict_txs))) { DETECT_LOG(WARN, "register or replace list failed", PRINT_WRAPPER); } else { // do nothing, register success or keep retrying