support tmfail

This commit is contained in:
obdev
2023-07-13 05:48:12 +00:00
committed by ob-robot
parent 3085e8d063
commit 434d463a5e
3 changed files with 43 additions and 29 deletions

View File

@ -1664,6 +1664,12 @@ int ObXACtx::xa_end(const ObXATransID &xid,
// include branch fail
TRANS_LOG(WARN, "check for execution failed", K(ret), K(xid), K(*this));
} else {
if (ObXAFlag::contain_tmfail(flags) && !tx_desc_->need_rollback()) {
if (OB_FAIL(MTL(ObTransService *)->abort_tx(*tx_desc_, ObTxAbortCause::IMPLICIT_ROLLBACK))) {
TRANS_LOG(WARN, "abort tx fail", K(ret), K(*this));
}
}
if (OB_SUCC(ret)) {
if (!is_tightly_coupled_) {
// loosely coupled mode
if (is_original) {
@ -1688,6 +1694,7 @@ int ObXACtx::xa_end(const ObXATransID &xid,
}
}
}
}
if (OB_SUCC(ret) && OB_FAIL(remove_xa_stmt_info_(xid))) {
TRANS_LOG(WARN, "remove xa stmt info failed", K(ret), K(xid), K(*this));
}

View File

@ -228,6 +228,10 @@ bool ObXAFlag::is_valid(const int64_t flag, const int64_t xa_req_type)
switch (xa_req_type) {
case ObXAReqType::XA_START: {
if (((flag & TMRESUME) && ((flag & TMJOIN) || (flag & LOOSELY)))
|| ((flag & LOOSELY) && (flag & TMJOIN))) {
ret_bool = false;
} else {
const bool is_resumejoin = flag & (TMRESUME | TMJOIN);
if (!is_resumejoin) {
const int64_t mask = LOOSELY | TMREADONLY | TMSERIALIZABLE;
@ -243,11 +247,12 @@ bool ObXAFlag::is_valid(const int64_t flag, const int64_t xa_req_type)
ret_bool = true;
}
}
}
break;
}
case ObXAReqType::XA_END: {
const int64_t mask = 0x00000000FFFFFFFF;
if ((flag & mask) != TMSUSPEND && (flag & mask) != TMSUCCESS) {
if ((flag & mask) != TMSUSPEND && (flag & mask) != TMSUCCESS && (flag & mask) != TMFAIL) {
ret_bool = false;
} else {
ret_bool = true;

View File

@ -115,6 +115,7 @@ public:
TMSUSPEND = 0x2000000,
TMSUCCESS = 0x4000000,
TMRESUME = 0x8000000,
TMFAIL = 0x20000000,
TMONEPHASE = 0x40000000,
// non-standard xa protocol, to denote temp table xa trans
TEMPTABLE = 0x100000000,
@ -137,6 +138,7 @@ public:
static bool contain_tmsuspend(const int64_t flag) { return flag & TMSUSPEND; }
static bool contain_tmonephase(const int64_t flag) { return flag & TMONEPHASE; }
static bool is_tmonephase(const int64_t flag) { return flag == TMONEPHASE; }
static bool contain_tmfail(const int64_t flag) { return flag & TMFAIL; }
static int64_t add_end_flag(const int64_t flag, const int64_t end_flag)
{
int64_t ret = end_flag;