[master] return DEADLOCK error when acquire snapshot is interrupted by deadlock detector

This commit is contained in:
chinaxing
2023-04-18 15:44:47 +00:00
committed by ob-robot
parent 49b1e7d35d
commit ee8473f401
2 changed files with 7 additions and 3 deletions

View File

@ -596,6 +596,7 @@ public:
|| state_ == State::COMMIT_UNKNOWN
|| state_ == State::ROLLED_BACK;
}
bool is_aborted() const { return state_ == State::ABORTED; }
bool is_tx_timeout() { return ObClockGenerator::getClock() > expire_ts_; }
bool is_tx_commit_timeout() { return ObClockGenerator::getClock() > commit_expire_ts_;}
void set_xa_ctx(ObXACtx *xa_ctx);

View File

@ -1549,9 +1549,12 @@ int ObTransService::sync_acquire_global_snapshot_(ObTxDesc &tx,
tx.flags_.BLOCK_ = false;
if (OB_SUCC(ret)) {
if (op_sn != tx.op_sn_) {
if (interrupted) {
ret = OB_ERR_INTERRUPTED;
TRANS_LOG(WARN, "txn has been interrupted", KR(ret), K(tx));
if (tx.is_aborted()) {
ret = tx.abort_cause_ == OB_DEAD_LOCK ? OB_DEAD_LOCK : OB_TRANS_KILLED;
TRANS_LOG(WARN, "txn has been aborted", KR(ret), K(tx.abort_cause_));
} else if (interrupted) {
ret = OB_ERR_INTERRUPTED;
TRANS_LOG(WARN, "txn has been interrupted", KR(ret), K(tx));
} else {
ret = OB_ERR_UNEXPECTED;
TRANS_LOG(WARN, "txn has been disturbed", KR(ret), K(tx));