提交 9bcdbcde 编写于 作者: O obdev 提交者: ob-robot

[4.1][savepoint] stop rollback to savepoint when trans is terminated

上级 9407bbea
......@@ -1571,8 +1571,19 @@ inline int ObTransService::sync_rollback_savepoint__(ObTxDesc &tx,
int rpc_ret = OB_SUCCESS;
if (OB_FAIL(tx.rpc_cond_.wait(waittime, rpc_ret))) {
TRANS_LOG(WARN, "tx rpc condition wakeup", K(ret),
K(waittime), K(rpc_ret), K(expire_ts), K(remain), K(remain_cnt), K(retries));
ret = OB_SUCCESS;
K(waittime), K(rpc_ret), K(expire_ts), K(remain), K(remain_cnt), K(retries),
K_(tx.state));
// if trans is terminated, rollback savepoint should be terminated
// NOTE that this case is only for xa trans
// EXAMPLE, tx desc is shared by branch 1 and branch 2
// 1. branch 1 starts to rollback savepoint
// 2. branch 2 is terminated
// 3. branch 1 receives callback of rollback savepoint
if (tx.is_terminated()) {
ret = OB_TRANS_HAS_DECIDED;
} else {
ret = OB_SUCCESS;
}
}
if (OB_SUCCESS != rpc_ret) {
TRANS_LOG(WARN, "tx rpc fail", K(rpc_ret), K_(tx.tx_id), K(waittime), K(remain), K(remain_cnt), K(retries));
......
......@@ -2209,20 +2209,28 @@ int ObXAService::terminate_to_original_(const ObXATransID &xid,
int ObXAService::xa_rollback_all_changes(const ObXATransID &xid, ObTxDesc *&tx_desc, const int64_t stmt_expired_time)
{
int ret = OB_SUCCESS;
int tmp_ret = OB_SUCCESS;
const int64_t savepoint = 1;
if (NULL == tx_desc || !tx_desc->is_valid() || !xid.is_valid() || stmt_expired_time < 0) {
ret = OB_INVALID_ARGUMENT;
TRANS_LOG(WARN, "invalid argument", K(ret), KP(tx_desc), K(xid), K(stmt_expired_time));
} else {
ObTransID tx_id = tx_desc->get_tx_id();
if (OB_FAIL(start_stmt(xid, 0/*unused session id*/, *tx_desc))) {
TRANS_LOG(WARN, "xa start stmt fail", K(ret), K(tx_desc), K(xid));
} else if (OB_FAIL(MTL(transaction::ObTransService *)->rollback_to_implicit_savepoint(*tx_desc, savepoint, stmt_expired_time, NULL))) {
TRANS_LOG(WARN, "do savepoint rollback error", K(ret), K(tx_desc));
} else if (OB_FAIL(end_stmt(xid, *tx_desc))) {
TRANS_LOG(WARN, "xa start stmt fail", K(ret), K(tx_desc), K(xid));
TRANS_LOG(WARN, "xa start stmt fail", K(ret), K(xid), K(tx_id));
} else {
TRANS_LOG(INFO, "xa rollback all changes success", K(ret), K(tx_desc), K(xid));
if (OB_FAIL(MTL(transaction::ObTransService *)->rollback_to_implicit_savepoint(*tx_desc,
savepoint, stmt_expired_time, NULL))) {
TRANS_LOG(WARN, "do savepoint rollback error", K(ret), K(xid), K(tx_id));
} else {
TRANS_LOG(INFO, "xa rollback all changes success", K(ret), K(xid), K(tx_id));
}
if (OB_SUCCESS != (tmp_ret = end_stmt(xid, *tx_desc))) {
// return the error code of end stmt first
ret = tmp_ret;
TRANS_LOG(WARN, "xa end stmt fail", K(ret), K(xid), K(tx_id));
}
}
}
return ret;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册