diff --git a/src/storage/transaction/ob_trans_sche_ctx.cpp b/src/storage/transaction/ob_trans_sche_ctx.cpp index c6c5bc2ab33c0ff4c78439c2366afbe31ba995b8..d7aab8a48f657fe0eadcd576955ea50210ae2872 100644 --- a/src/storage/transaction/ob_trans_sche_ctx.cpp +++ b/src/storage/transaction/ob_trans_sche_ctx.cpp @@ -3159,6 +3159,9 @@ int ObScheTransCtx::xa_one_phase_end_trans(const bool is_rollback) ret = OB_TRANS_XA_RETRY; } } + } else if (!is_rollback && trans_desc_->need_rollback()) { + ret = OB_TRANS_NEED_ROLLBACK; + TRANS_LOG(WARN, "transaction need rollback", K(ret), K(*this)); } else { if (OB_FAIL(xa_one_phase_end_trans_(is_rollback))) { TRANS_LOG(WARN, "xa one phase end trans failed", K(ret), K(is_rollback), K(*this)); @@ -3377,6 +3380,9 @@ int ObScheTransCtx::xa_sync_status_response(const ObTransDesc& trans_desc, const tmp_trans_desc_->set_stmt_min_sql_no(trans_desc.get_stmt_min_sql_no()); sql_no_ = trans_desc.get_sql_no(); tmp_trans_desc_->get_trans_param() = trans_desc.get_trans_param(); + if (trans_desc.need_rollback()) { + tmp_trans_desc_->set_need_rollback(); + } if (OB_FAIL(tmp_trans_desc_->merge_participants(trans_desc.get_participants()))) { TRANS_LOG(WARN, "merge participants failed", K(ret)); } else if (OB_FAIL(tmp_trans_desc_->merge_participants_pla(trans_desc.get_participants_pla()))) { diff --git a/src/storage/transaction/ob_xa_trans_service.cpp b/src/storage/transaction/ob_xa_trans_service.cpp index 4cbf1a2b78ccb83897f03d330870f68ac7d0a556..5b7a9b2f405c05a74f57fa8d76380abc94d82655 100644 --- a/src/storage/transaction/ob_xa_trans_service.cpp +++ b/src/storage/transaction/ob_xa_trans_service.cpp @@ -904,6 +904,9 @@ int ObTransService::local_xa_prepare(const ObXATransID& xid, const int64_t stmt_ if (!trans_desc->is_valid()) { ret = OB_ERR_UNEXPECTED; TRANS_LOG(WARN, "invalid trans dessc", K(ret), K(xid), K(trans_desc)); + } else if (trans_desc->need_rollback()) { + ret = OB_TRANS_NEED_ROLLBACK; + TRANS_LOG(WARN, "transaction need rollback", K(ret), K(xid), K(trans_desc)); } else if (OB_FAIL(trans_desc->set_sche_ctx(sche_ctx))) { TRANS_LOG(WARN, "set trans_desc failed", K(ret), K(xid), K(trans_desc)); // TODO, refer to the remote xa prepare to handle the case that ctx does not exist