diff --git a/src/storage/tx/ob_ctx_tx_data.h b/src/storage/tx/ob_ctx_tx_data.h index e556db9e2..c29b791d7 100644 --- a/src/storage/tx/ob_ctx_tx_data.h +++ b/src/storage/tx/ob_ctx_tx_data.h @@ -35,6 +35,8 @@ public: void destroy(); int init(ObLSTxCtxMgr *ctx_mgr, int64_t tx_id); + + bool is_read_only() const { return read_only_; } int insert_into_tx_table(); int recover_tx_data(const storage::ObTxData *tmp_tx_data); int replace_tx_data(storage::ObTxData *&tmp_tx_data); diff --git a/src/storage/tx/ob_trans_part_ctx.cpp b/src/storage/tx/ob_trans_part_ctx.cpp index 95b6bf0dd..d13a89c97 100644 --- a/src/storage/tx/ob_trans_part_ctx.cpp +++ b/src/storage/tx/ob_trans_part_ctx.cpp @@ -4170,6 +4170,8 @@ int ObPartTransCtx::replay_commit(const ObTxCommitLog &commit_log, true, exec_info_.multi_data_source_))) { TRANS_LOG(WARN, "notify data source failed", KR(ret), K(commit_log)); + } else if ((!ctx_tx_data_.is_read_only()) && OB_FAIL(ctx_tx_data_.insert_into_tx_table())) { + TRANS_LOG(WARN, "insert to tx table failed", KR(ret), K(*this)); } else if (is_local_tx_()) { if (OB_FAIL(trans_clear_())) { TRANS_LOG(WARN, "transaction clear error or trans_type is sp_trans", KR(ret), "context", *this); @@ -4181,9 +4183,6 @@ int ObPartTransCtx::replay_commit(const ObTxCommitLog &commit_log, } if (OB_SUCC(ret)) { sub_state_.set_state_log_submitted(); - if (OB_FAIL(ctx_tx_data_.insert_into_tx_table())) { - TRANS_LOG(WARN, "insert to tx table failed", KR(ret), K(*this)); - } } const int64_t used_time = timeguard.get_diff(); @@ -4334,6 +4333,8 @@ int ObPartTransCtx::replay_abort(const ObTxAbortLog &abort_log, TRANS_LOG(WARN, "transaction clear error", KR(ret), "context", *this); } else if (OB_FAIL(notify_data_source_(NotifyType::ON_ABORT, timestamp, true, tmp_array))) { TRANS_LOG(WARN, "notify data source failed", KR(ret), K(abort_log)); + } else if ((!ctx_tx_data_.is_read_only()) && OB_FAIL(ctx_tx_data_.insert_into_tx_table())) { + TRANS_LOG(WARN, "insert to tx table failed", KR(ret), K(*this)); } else { reset_redo_lsns_(); set_exiting_(); @@ -4341,9 +4342,6 @@ int ObPartTransCtx::replay_abort(const ObTxAbortLog &abort_log, } if (OB_SUCC(ret)) { sub_state_.set_state_log_submitted(); - if (OB_FAIL(ctx_tx_data_.insert_into_tx_table())) { - TRANS_LOG(WARN, "insert to tx table failed", KR(ret), K(*this)); - } } const int64_t used_time = timeguard.get_diff(); REC_TRANS_TRACE_EXT2(tlog_, replay_abort, OB_ID(ret), ret, OB_ID(used),