From 6f5d889cdb2c89f807cb62ecd3ce982e4061ddc4 Mon Sep 17 00:00:00 2001 From: obdev Date: Tue, 27 Dec 2022 10:38:19 +0000 Subject: [PATCH] [4.1] fix handle timeout for one participant distributed trans --- .../tx/ob_two_phase_upstream_committer.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/storage/tx/ob_two_phase_upstream_committer.cpp b/src/storage/tx/ob_two_phase_upstream_committer.cpp index 0151e2eaf..16ce45ee7 100644 --- a/src/storage/tx/ob_two_phase_upstream_committer.cpp +++ b/src/storage/tx/ob_two_phase_upstream_committer.cpp @@ -239,6 +239,21 @@ int ObTxCycleTwoPhaseCommitter::handle_timeout() TRANS_LOG(WARN, "retransmit upstream msg failed", KR(tmp_ret)); } + // if a distributed trans has one participant and its 2pc state (up and down) is prepare, + // then try enter into pre commit state. + // NOTE that if a distributed trans has at least two participants, + // the state can be drived by message. + if (is_root()) { + const int SINGLE_COUNT = 1; + if (SINGLE_COUNT == get_downstream_size() + && ObTxState::PREPARE == get_downstream_state() + && ObTxState::PREPARE == get_upstream_state()) { + if (OB_FAIL(try_enter_pre_commit_state())) { + TRANS_LOG(WARN, "try enter into pre commit state failed", K(ret)); + } + } + } + return ret; }