diff --git a/src/sql/ob_sql_trans_control.cpp b/src/sql/ob_sql_trans_control.cpp index d6aa4dac02..3ee1723bdf 100644 --- a/src/sql/ob_sql_trans_control.cpp +++ b/src/sql/ob_sql_trans_control.cpp @@ -461,7 +461,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())); + OZ (txs->sql_stmt_start_hook(session->get_xid(), *session->get_tx_desc(), session->get_sessid())); if (OB_SUCC(ret) && txs->get_tx_elr_util().check_and_update_tx_elr_info( *session->get_tx_desc(), diff --git a/src/storage/tx/ob_trans_define_v4.h b/src/storage/tx/ob_trans_define_v4.h index 87afe6520b..4554c3689f 100644 --- a/src/storage/tx/ob_trans_define_v4.h +++ b/src/storage/tx/ob_trans_define_v4.h @@ -532,6 +532,7 @@ public: void set_xa_ctx(ObXACtx *xa_ctx) { xa_ctx_ = xa_ctx; } ObXACtx *get_xa_ctx() { return xa_ctx_; } void set_xid(const ObXATransID &xid) { xid_ = xid; } + void set_sessid(const uint32_t session_id) { sess_id_ = session_id; } const ObXATransID &get_xid() const { return xid_; } bool is_xa_trans() const { return !xid_.empty(); } void reset_for_xa() { xid_.reset(); xa_ctx_ = NULL; } diff --git a/src/storage/tx/ob_tx_api.cpp b/src/storage/tx/ob_tx_api.cpp index b182006a4f..80f566e64b 100644 --- a/src/storage/tx/ob_tx_api.cpp +++ b/src/storage/tx/ob_tx_api.cpp @@ -1705,14 +1705,16 @@ int ObTransService::is_tx_active(const ObTransID &tx_id, bool &active) } return ret; } -int ObTransService::sql_stmt_start_hook(const ObXATransID &xid, ObTxDesc &tx) +int ObTransService::sql_stmt_start_hook(const ObXATransID &xid, ObTxDesc &tx, const uint32_t session_id) { int ret = OB_SUCCESS; if (tx.is_xa_trans()) { if (OB_FAIL(MTL(ObXAService*)->start_stmt(xid, tx))) { TRANS_LOG(WARN, "xa trans start stmt failed", K(ret), K_(tx.xid), K(xid)); + } else { + tx.set_sessid(session_id); } - TRANS_LOG(INFO, "xa trans start stmt", K_(tx.xid), K(xid)); + TRANS_LOG(INFO, "xa trans start stmt", K_(tx.xid), K(xid), K_(tx.sess_id), K(session_id)); } return ret; } diff --git a/src/storage/tx/ob_tx_api.h b/src/storage/tx/ob_tx_api.h index 82353957ab..4154f8efa7 100644 --- a/src/storage/tx/ob_tx_api.h +++ b/src/storage/tx/ob_tx_api.h @@ -539,5 +539,5 @@ 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); +int sql_stmt_start_hook(const ObXATransID &xid, ObTxDesc &tx, const uint32_t session_id); int sql_stmt_end_hook(const ObXATransID &xid, ObTxDesc &tx); diff --git a/src/storage/tx/ob_xa_service.cpp b/src/storage/tx/ob_xa_service.cpp index 79a56c488e..b2f9ab77d8 100644 --- a/src/storage/tx/ob_xa_service.cpp +++ b/src/storage/tx/ob_xa_service.cpp @@ -1387,7 +1387,7 @@ int ObXAService::end_stmt(const ObXATransID &xid, ObTxDesc &tx_desc) if (NULL == xa_ctx) { ret = OB_ERR_UNEXPECTED; TRANS_LOG(WARN, "unexpected trans descriptor", K(ret), K(tx_id), K(xid)); - } else if (xa_ctx->end_stmt(xid)) { + } else if (OB_FAIL(xa_ctx->end_stmt(xid))) { TRANS_LOG(WARN, "xa trans end stmt failed", K(ret), K(tx_id), K(xid)); } else { TRANS_LOG(INFO, "xa trans end stmt", K(ret), K(tx_id), K(xid));