diff --git a/src/sql/ob_sql_trans_control.cpp b/src/sql/ob_sql_trans_control.cpp index fdf573f37..7de883de5 100644 --- a/src/sql/ob_sql_trans_control.cpp +++ b/src/sql/ob_sql_trans_control.cpp @@ -425,6 +425,7 @@ int ObSqlTransControl::do_end_trans_(ObSQLSessionInfo *session, } if (session->associated_xa() && !is_explicit) { ret = OB_TRANS_XA_RMFAIL; + LOG_ERROR("executing do end trans in xa", K(ret), K(session->get_xid()), KPC(tx_ptr)); } else { /* * normal transaction control @@ -504,7 +505,7 @@ int ObSqlTransControl::start_stmt(ObExecContext &exec_ctx) OZ (get_tx_service(session, txs), tenant_id); OZ (acquire_tx_if_need_(txs, *session)); OZ (stmt_sanity_check_(session, plan, plan_ctx)); - OZ (txs->sql_stmt_start_hook(session->get_xid(), *session->get_tx_desc(), session->get_sessid())); + OZ (txs->sql_stmt_start_hook(session->get_xid(), *session->get_tx_desc(), session->get_sessid(), get_real_session_id(*session))); bool start_hook = OB_SUCC(ret) && !session->get_xid().empty() ? true : false; if (OB_SUCC(ret) && txs->get_tx_elr_util().check_and_update_tx_elr_info(*session->get_tx_desc())) { @@ -744,7 +745,7 @@ int ObSqlTransControl::start_hook_if_need_(ObSQLSessionInfo &session, { int ret = OB_SUCCESS; if (!session.get_tx_desc()->is_shadow() && !session.has_start_stmt() && - OB_SUCC(txs->sql_stmt_start_hook(session.get_xid(), *session.get_tx_desc(), session.get_sessid()))) { + OB_SUCC(txs->sql_stmt_start_hook(session.get_xid(), *session.get_tx_desc(), session.get_sessid(), get_real_session_id(session)))) { start_hook = true; } return ret; diff --git a/src/storage/tx/ob_tx_api.cpp b/src/storage/tx/ob_tx_api.cpp index 64da66026..e35c3dff0 100644 --- a/src/storage/tx/ob_tx_api.cpp +++ b/src/storage/tx/ob_tx_api.cpp @@ -1758,7 +1758,10 @@ int ObTransService::is_tx_active(const ObTransID &tx_id, bool &active) } return ret; } -int ObTransService::sql_stmt_start_hook(const ObXATransID &xid, ObTxDesc &tx, const uint32_t session_id) +int ObTransService::sql_stmt_start_hook(const ObXATransID &xid, + ObTxDesc &tx, + const uint32_t session_id, + const uint32_t real_session_id) { int ret = OB_SUCCESS; if (tx.is_xa_trans()) { @@ -1770,7 +1773,7 @@ int ObTransService::sql_stmt_start_hook(const ObXATransID &xid, ObTxDesc &tx, co TRANS_LOG(WARN, "register tx fail", K(ret), K_(tx.tx_id), K(xid), KP(&tx)); } else { registed = true; } } - if (OB_SUCC(ret) && OB_FAIL(MTL(ObXAService*)->start_stmt(xid, session_id, tx))) { + if (OB_SUCC(ret) && OB_FAIL(MTL(ObXAService*)->start_stmt(xid, real_session_id, tx))) { TRANS_LOG(WARN, "xa trans start stmt failed", K(ret), K_(tx.xid), K(xid)); ObGlobalTxType global_tx_type = tx.get_global_tx_type(xid); if (ObGlobalTxType::DBLINK_TRANS == global_tx_type && OB_TRANS_XA_BRANCH_FAIL == ret) { diff --git a/src/storage/tx/ob_tx_api.h b/src/storage/tx/ob_tx_api.h index cb8249df2..63e7372cc 100644 --- a/src/storage/tx/ob_tx_api.h +++ b/src/storage/tx/ob_tx_api.h @@ -545,5 +545,8 @@ int is_tx_active(const ObTransID &tx_id, bool &active); * between tighly couple branchs around the SQL stmt * these hooks place on stmt start and end position to handle these works *****************************************************************************/ -int sql_stmt_start_hook(const ObXATransID &xid, ObTxDesc &tx, const uint32_t session_id); +int sql_stmt_start_hook(const ObXATransID &xid, + ObTxDesc &tx, + const uint32_t session_id, + const uint32_t real_session_id); int sql_stmt_end_hook(const ObXATransID &xid, ObTxDesc &tx);