return ob_not_master if txn was killed by LS GC routine

This commit is contained in:
chinaxing
2023-03-15 04:41:08 +00:00
committed by ob-robot
parent e04e3c9410
commit 74a77359bd
2 changed files with 25 additions and 13 deletions

View File

@ -563,13 +563,18 @@ int ObTableScanIterator::check_txn_status_if_read_uncommitted_()
{ {
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
auto &acc_ctx = ctx_guard_.get_store_ctx().mvcc_acc_ctx_; auto &acc_ctx = ctx_guard_.get_store_ctx().mvcc_acc_ctx_;
auto &snapshot = acc_ctx.snapshot_; if (acc_ctx.snapshot_.tx_id_.is_valid() && acc_ctx.mem_ctx_) {
if (snapshot.tx_id_.is_valid() && acc_ctx.mem_ctx_) {
if (acc_ctx.mem_ctx_->is_tx_rollbacked()) { if (acc_ctx.mem_ctx_->is_tx_rollbacked()) {
// The txn has been killed during normal processing. So we return if (acc_ctx.mem_ctx_->is_for_replay()) {
// OB_TRANS_KILLED to prompt this abnormal state. // goes here means the txn was killed due to LS's GC etc,
ret = OB_TRANS_KILLED; // return NOT_MASTER
STORAGE_LOG(WARN, "txn termianted when table scan", K(ret), K(acc_ctx)); ret = OB_NOT_MASTER;
} else {
// The txn has been killed during normal processing. So we return
// OB_TRANS_KILLED to prompt this abnormal state.
ret = OB_TRANS_KILLED;
STORAGE_LOG(WARN, "txn has terminated", K(ret), "tx_id", acc_ctx.tx_id_);
}
} }
} }
return ret; return ret;

View File

@ -293,13 +293,20 @@ int ObSingleRowGetter::get_next_row(ObNewRow *&row)
} }
if (OB_SUCC(ret) || OB_ITER_END == ret) { if (OB_SUCC(ret) || OB_ITER_END == ret) {
// check txn status not aborted, which cause readout incorrect result // check txn status not aborted, which cause readout incorrect result
if (store_ctx_->mvcc_acc_ctx_.snapshot_.tx_id_.is_valid() && auto &acc_ctx = store_ctx_->mvcc_acc_ctx_;
store_ctx_->mvcc_acc_ctx_.mem_ctx_ && if (acc_ctx.snapshot_.tx_id_.is_valid() &&
store_ctx_->mvcc_acc_ctx_.mem_ctx_->is_tx_rollbacked()) { acc_ctx.mem_ctx_ &&
// The txn has been killed during normal processing. So we return acc_ctx.mem_ctx_->is_tx_rollbacked()) {
// OB_TRANS_KILLED to prompt this abnormal state. if (acc_ctx.mem_ctx_->is_for_replay()) {
ret = OB_TRANS_KILLED; // goes here means the txn was killed due to LS's GC etc,
STORAGE_LOG(WARN, "txn has terminated", K(ret)); // return NOT_MASTER
ret = OB_NOT_MASTER;
} else {
// The txn has been killed during normal processing. So we return
// OB_TRANS_KILLED to prompt this abnormal state.
ret = OB_TRANS_KILLED;
STORAGE_LOG(WARN, "txn has terminated", K(ret), "tx_id", acc_ctx.tx_id_);
}
} }
} }
return ret; return ret;