[4.1][xa] abort tx before release tx when fail in xa start
This commit is contained in:
@ -1540,6 +1540,7 @@ int ObXACtx::xa_start_remote_first_(const ObXATransID &xid,
|
|||||||
TRANS_LOG(WARN, "update xa stmt info failed", K(ret), K(xid), K(*this));
|
TRANS_LOG(WARN, "update xa stmt info failed", K(ret), K(xid), K(*this));
|
||||||
} else {
|
} else {
|
||||||
// xa_ref_count_ is added only when success is returned
|
// xa_ref_count_ is added only when success is returned
|
||||||
|
xa_trans_state_ = ObXATransState::ACTIVE;
|
||||||
++xa_ref_count_;
|
++xa_ref_count_;
|
||||||
tx_desc_->set_xid(xid);
|
tx_desc_->set_xid(xid);
|
||||||
tx_desc_->set_xa_ctx(this);
|
tx_desc_->set_xa_ctx(this);
|
||||||
|
|||||||
@ -186,9 +186,9 @@ int ObXAService::xa_start_for_tm_promotion_(const int64_t flags,
|
|||||||
if (OB_SUCC(ret)) {
|
if (OB_SUCC(ret)) {
|
||||||
//commit record
|
//commit record
|
||||||
if (OB_FAIL(trans.end(true))) {
|
if (OB_FAIL(trans.end(true))) {
|
||||||
|
// NOTE that if fail, do not release tx desc
|
||||||
TRANS_LOG(WARN, "commit inner table trans failed", K(ret), K(xid));
|
TRANS_LOG(WARN, "commit inner table trans failed", K(ret), K(xid));
|
||||||
const bool need_decrease_ref = true;
|
xa_ctx_mgr_.erase_xa_ctx(tx_id);
|
||||||
xa_ctx->try_exit(need_decrease_ref);
|
|
||||||
xa_ctx_mgr_.revert_xa_ctx(xa_ctx);
|
xa_ctx_mgr_.revert_xa_ctx(xa_ctx);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -197,7 +197,7 @@ int ObXAService::xa_start_for_tm_promotion_(const int64_t flags,
|
|||||||
TRANS_LOG(WARN, "rollback inner table trans failed", K(tmp_ret), K(xid));
|
TRANS_LOG(WARN, "rollback inner table trans failed", K(tmp_ret), K(xid));
|
||||||
}
|
}
|
||||||
if (OB_NOT_NULL(xa_ctx)) {
|
if (OB_NOT_NULL(xa_ctx)) {
|
||||||
xa_ctx_mgr_.erase_xa_ctx(trans_id);
|
xa_ctx_mgr_.erase_xa_ctx(tx_id);
|
||||||
xa_ctx_mgr_.revert_xa_ctx(xa_ctx);
|
xa_ctx_mgr_.revert_xa_ctx(xa_ctx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -318,6 +318,10 @@ int ObXAService::xa_start_for_tm_(const int64_t flags,
|
|||||||
}
|
}
|
||||||
if (OB_FAIL(ret)) {
|
if (OB_FAIL(ret)) {
|
||||||
TRANS_LOG(WARN, "start trans failed", K(ret), K(tx_id), K(xid));
|
TRANS_LOG(WARN, "start trans failed", K(ret), K(tx_id), K(xid));
|
||||||
|
if (OB_SUCCESS != (tmp_ret = MTL(ObTransService*)->abort_tx(*tx_desc,
|
||||||
|
ObTxAbortCause::IMPLICIT_ROLLBACK))) {
|
||||||
|
TRANS_LOG(WARN, "fail to abort transaction", K(tmp_ret), K(tx_id), K(xid));
|
||||||
|
}
|
||||||
MTL(ObTransService *)->release_tx(*tx_desc);
|
MTL(ObTransService *)->release_tx(*tx_desc);
|
||||||
tx_desc = NULL;
|
tx_desc = NULL;
|
||||||
} else if (OB_FAIL(insert_xa_record(trans, tenant_id, xid, tx_id, sche_addr, flags))) {
|
} else if (OB_FAIL(insert_xa_record(trans, tenant_id, xid, tx_id, sche_addr, flags))) {
|
||||||
@ -331,6 +335,10 @@ int ObXAService::xa_start_for_tm_(const int64_t flags,
|
|||||||
TRANS_LOG(WARN, "rollback lock record failed", K(tmp_ret), K(xid));
|
TRANS_LOG(WARN, "rollback lock record failed", K(tmp_ret), K(xid));
|
||||||
}
|
}
|
||||||
// txs_->remove_tx(*tx_desc);
|
// txs_->remove_tx(*tx_desc);
|
||||||
|
if (OB_SUCCESS != (tmp_ret = MTL(ObTransService*)->abort_tx(*tx_desc,
|
||||||
|
ObTxAbortCause::IMPLICIT_ROLLBACK))) {
|
||||||
|
TRANS_LOG(WARN, "fail to abort transaction", K(tmp_ret), K(tx_id), K(xid));
|
||||||
|
}
|
||||||
MTL(ObTransService *)->release_tx(*tx_desc);
|
MTL(ObTransService *)->release_tx(*tx_desc);
|
||||||
tx_desc = NULL;
|
tx_desc = NULL;
|
||||||
} else {
|
} else {
|
||||||
@ -362,6 +370,10 @@ int ObXAService::xa_start_for_tm_(const int64_t flags,
|
|||||||
if (OB_FAIL(trans.end(true))) {
|
if (OB_FAIL(trans.end(true))) {
|
||||||
TRANS_LOG(WARN, "commit inner table trans failed", K(ret), K(xid));
|
TRANS_LOG(WARN, "commit inner table trans failed", K(ret), K(xid));
|
||||||
const bool need_decrease_ref = true;
|
const bool need_decrease_ref = true;
|
||||||
|
if (OB_SUCCESS != (tmp_ret = MTL(ObTransService*)->abort_tx(*tx_desc,
|
||||||
|
ObTxAbortCause::IMPLICIT_ROLLBACK))) {
|
||||||
|
TRANS_LOG(WARN, "fail to abort transaction", K(tmp_ret), K(tx_id), K(xid));
|
||||||
|
}
|
||||||
xa_ctx->try_exit(need_decrease_ref);
|
xa_ctx->try_exit(need_decrease_ref);
|
||||||
xa_ctx_mgr_.revert_xa_ctx(xa_ctx);
|
xa_ctx_mgr_.revert_xa_ctx(xa_ctx);
|
||||||
tx_desc = NULL;
|
tx_desc = NULL;
|
||||||
@ -372,10 +384,14 @@ int ObXAService::xa_start_for_tm_(const int64_t flags,
|
|||||||
TRANS_LOG(WARN, "rollback inner table trans failed", K(tmp_ret), K(xid));
|
TRANS_LOG(WARN, "rollback inner table trans failed", K(tmp_ret), K(xid));
|
||||||
}
|
}
|
||||||
if (OB_NOT_NULL(xa_ctx)) {
|
if (OB_NOT_NULL(xa_ctx)) {
|
||||||
xa_ctx_mgr_.erase_xa_ctx(trans_id);
|
xa_ctx_mgr_.erase_xa_ctx(tx_id);
|
||||||
xa_ctx_mgr_.revert_xa_ctx(xa_ctx);
|
xa_ctx_mgr_.revert_xa_ctx(xa_ctx);
|
||||||
}
|
}
|
||||||
// since tx_desc is not set into xa ctx, release tx desc explicitly
|
// since tx_desc is not set into xa ctx, release tx desc explicitly
|
||||||
|
if (OB_SUCCESS != (tmp_ret = MTL(ObTransService*)->abort_tx(*tx_desc,
|
||||||
|
ObTxAbortCause::IMPLICIT_ROLLBACK))) {
|
||||||
|
TRANS_LOG(WARN, "fail to abort transaction", K(tmp_ret), K(tx_id), K(xid));
|
||||||
|
}
|
||||||
MTL(ObTransService *)->release_tx(*tx_desc);
|
MTL(ObTransService *)->release_tx(*tx_desc);
|
||||||
tx_desc = NULL;
|
tx_desc = NULL;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1111,6 +1111,10 @@ int ObXAService::xa_start_(const ObXATransID &xid,
|
|||||||
TRANS_LOG(WARN, "rollback lock record failed", K(tmp_ret), K(xid));
|
TRANS_LOG(WARN, "rollback lock record failed", K(tmp_ret), K(xid));
|
||||||
}
|
}
|
||||||
if (is_first_xa_start) {
|
if (is_first_xa_start) {
|
||||||
|
if (OB_SUCCESS != (tmp_ret = MTL(ObTransService*)->abort_tx(*tx_desc,
|
||||||
|
ObTxAbortCause::IMPLICIT_ROLLBACK))) {
|
||||||
|
TRANS_LOG(WARN, "fail to abort transaction", K(tmp_ret), K(trans_id), K(xid));
|
||||||
|
}
|
||||||
MTL(ObTransService *)->release_tx(*tx_desc);
|
MTL(ObTransService *)->release_tx(*tx_desc);
|
||||||
tx_desc = NULL;
|
tx_desc = NULL;
|
||||||
}
|
}
|
||||||
@ -1143,6 +1147,10 @@ int ObXAService::xa_start_(const ObXATransID &xid,
|
|||||||
if (OB_FAIL(trans.end(true))) {
|
if (OB_FAIL(trans.end(true))) {
|
||||||
TRANS_LOG(WARN, "commit inner table trans failed", K(ret), K(xid));
|
TRANS_LOG(WARN, "commit inner table trans failed", K(ret), K(xid));
|
||||||
const bool need_decrease_ref = true;
|
const bool need_decrease_ref = true;
|
||||||
|
if (OB_SUCCESS != (tmp_ret = MTL(ObTransService*)->abort_tx(*tx_desc,
|
||||||
|
ObTxAbortCause::IMPLICIT_ROLLBACK))) {
|
||||||
|
TRANS_LOG(WARN, "fail to abort transaction", K(tmp_ret), K(trans_id), K(xid));
|
||||||
|
}
|
||||||
xa_ctx->try_exit(need_decrease_ref);
|
xa_ctx->try_exit(need_decrease_ref);
|
||||||
xa_ctx_mgr_.revert_xa_ctx(xa_ctx);
|
xa_ctx_mgr_.revert_xa_ctx(xa_ctx);
|
||||||
tx_desc = NULL;
|
tx_desc = NULL;
|
||||||
@ -1157,6 +1165,10 @@ int ObXAService::xa_start_(const ObXATransID &xid,
|
|||||||
xa_ctx_mgr_.revert_xa_ctx(xa_ctx);
|
xa_ctx_mgr_.revert_xa_ctx(xa_ctx);
|
||||||
}
|
}
|
||||||
// since tx_desc is not set into xa ctx, release tx desc explicitly
|
// since tx_desc is not set into xa ctx, release tx desc explicitly
|
||||||
|
if (OB_SUCCESS != (tmp_ret = MTL(ObTransService*)->abort_tx(*tx_desc,
|
||||||
|
ObTxAbortCause::IMPLICIT_ROLLBACK))) {
|
||||||
|
TRANS_LOG(WARN, "fail to abort transaction", K(tmp_ret), K(trans_id), K(xid));
|
||||||
|
}
|
||||||
MTL(ObTransService *)->release_tx(*tx_desc);
|
MTL(ObTransService *)->release_tx(*tx_desc);
|
||||||
tx_desc = NULL;
|
tx_desc = NULL;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user