diff --git a/src/storage/tx/ob_trans_define.cpp b/src/storage/tx/ob_trans_define.cpp index 639f7b7b1..9c0e2a875 100644 --- a/src/storage/tx/ob_trans_define.cpp +++ b/src/storage/tx/ob_trans_define.cpp @@ -610,6 +610,19 @@ int ObCoreLocalPartitionAuditInfo::init(int64_t array_len) return ret; } +bool ObStateInfo::need_update(const ObStateInfo &state_info) +{ + bool need_update = true; + if (ObTxState::PRE_COMMIT <= state_ && state_ <= ObTxState::CLEAR) { + need_update = false; + } else if (snapshot_version_ > state_info.snapshot_version_) { + need_update = false; + } else if (state_info.state_ < state_) { + need_update = false; + } + return need_update; +} + void ObAddrLogId::reset() { addr_.reset(); diff --git a/src/storage/tx/ob_trans_define.h b/src/storage/tx/ob_trans_define.h index bfb53ca4b..7e8216132 100644 --- a/src/storage/tx/ob_trans_define.h +++ b/src/storage/tx/ob_trans_define.h @@ -1468,6 +1468,7 @@ public: version_ = state_info.version_; snapshot_version_ = state_info.snapshot_version_; } + bool need_update(const ObStateInfo &state_info); TO_STRING_KV(K_(ls_id), K_(state), K_(version), K_(snapshot_version)) OB_UNIS_VERSION(1); public: diff --git a/src/storage/tx/ob_trans_part_ctx.cpp b/src/storage/tx/ob_trans_part_ctx.cpp index c438dde09..fe44f1031 100644 --- a/src/storage/tx/ob_trans_part_ctx.cpp +++ b/src/storage/tx/ob_trans_part_ctx.cpp @@ -7026,7 +7026,7 @@ int ObPartTransCtx::handle_trans_ask_state_resp(const ObAskStateRespMsg &msg) if (OB_FAIL(state_info_array_.push_back(msg.state_info_array_.at(i)))) { TRANS_LOG(WARN, "push back state info array fail", K(ret)); } - } else if (state_info_array_.at(j-1).snapshot_version_ < msg.state_info_array_.at(i).snapshot_version_) { + } else if (state_info_array_.at(j-1).need_update(msg.state_info_array_.at(i))) { state_info_array_.at(j-1) = msg.state_info_array_.at(i); } } @@ -7128,7 +7128,7 @@ int ObPartTransCtx::handle_trans_collect_state_resp(const ObCollectStateRespMsg if (!is_contain) { ret = OB_ERR_UNEXPECTED; TRANS_LOG(WARN, "state info array has wrong participiants", K(ret), K(msg), KPC(this)); - } else if (state_info_array_.at(i-1).snapshot_version_ < msg.state_info_.snapshot_version_) { + } else if (state_info_array_.at(i-1).need_update(msg.state_info_)) { state_info_array_.at(i-1) = msg.state_info_; } if (OB_SUCC(ret)) { diff --git a/src/storage/tx/ob_trans_service_v4.cpp b/src/storage/tx/ob_trans_service_v4.cpp index 8fa963fe6..d521de778 100644 --- a/src/storage/tx/ob_trans_service_v4.cpp +++ b/src/storage/tx/ob_trans_service_v4.cpp @@ -3188,7 +3188,7 @@ int ObTransService::check_and_fill_state_info(const ObTransID &tx_id, ObStateInf ret = OB_TRANS_CTX_NOT_EXIST; } else if (OB_FAIL(ls->get_ls_replica_readable_scn(version))) { TRANS_LOG(WARN, "get ls replica readable scn fail", K(ret), K(ls_id)); - } else if (version <= state_info.snapshot_version_) { + } else if (version >= state_info.snapshot_version_) { state_info.state_ = ObTxState::UNKNOWN; state_info.version_ = version; } else {