From 80ea36d9aba870e055039541e004c5c89a7d2164 Mon Sep 17 00:00:00 2001 From: obdev Date: Wed, 28 Dec 2022 04:08:13 +0000 Subject: [PATCH] [CP] only root participant need to request gts --- src/storage/tx/ob_trans_part_ctx.cpp | 10 ++++++---- src/storage/tx/ob_trans_part_ctx.h | 1 - src/storage/tx/ob_tx_2pc_ctx_impl.cpp | 15 --------------- 3 files changed, 6 insertions(+), 20 deletions(-) diff --git a/src/storage/tx/ob_trans_part_ctx.cpp b/src/storage/tx/ob_trans_part_ctx.cpp index 3e98c5777..550bb62cb 100644 --- a/src/storage/tx/ob_trans_part_ctx.cpp +++ b/src/storage/tx/ob_trans_part_ctx.cpp @@ -2138,11 +2138,10 @@ int ObPartTransCtx::generate_prepare_version_() SCN gts = SCN::min_scn(); SCN local_max_read_version = SCN::min_scn(); bool is_gts_ok = false; - bool need_gts = need_request_gts_(); + // Only the root participant require to request gts + const bool need_gts = is_root(); - // Only the first participant in the participants list of the root require - // to request gts - if (is_root() && need_gts) { + if (need_gts) { if (OB_FAIL(get_gts_(gts))) { if (OB_EAGAIN == ret) { is_gts_ok = false; @@ -2169,6 +2168,9 @@ int ObPartTransCtx::generate_prepare_version_() TRANS_LOG(WARN, "get local max read version failed", KR(ret), K(*this)); } else { exec_info_.prepare_version_ = std::max(gts, local_max_read_version); + if (exec_info_.prepare_version_ > gts) { + mt_ctx_.before_prepare(exec_info_.prepare_version_); + } } } } diff --git a/src/storage/tx/ob_trans_part_ctx.h b/src/storage/tx/ob_trans_part_ctx.h index c92dc11b8..0a5e15ec9 100644 --- a/src/storage/tx/ob_trans_part_ctx.h +++ b/src/storage/tx/ob_trans_part_ctx.h @@ -632,7 +632,6 @@ protected: private: // int tx_end_(const bool commit, const int64_t commit_version); - bool need_request_gts_(); void register_gts_callback_(); int restart_2pc_trans_timer_(); // ============================ TX COMMITTER END ============================ diff --git a/src/storage/tx/ob_tx_2pc_ctx_impl.cpp b/src/storage/tx/ob_tx_2pc_ctx_impl.cpp index 5fd09bd01..c4e526f74 100644 --- a/src/storage/tx/ob_tx_2pc_ctx_impl.cpp +++ b/src/storage/tx/ob_tx_2pc_ctx_impl.cpp @@ -345,21 +345,6 @@ int ObPartTransCtx::on_clear() return ret; } -bool ObPartTransCtx::need_request_gts_() -{ - bool bret = false; - - if (!is_leaf()) { - if (0 != exec_info_.participants_.count() - && ls_id_ == exec_info_.participants_[0]) { - bret = true; - } else { - bret = false; - } - } - return bret; -} - int ObPartTransCtx::reply_to_scheduler_for_sub2pc(int64_t msg_type) { int ret = OB_SUCCESS;