diff --git a/src/gausskernel/process/tcop/utility.cpp b/src/gausskernel/process/tcop/utility.cpp index ee87bc303..b4f3303f9 100755 --- a/src/gausskernel/process/tcop/utility.cpp +++ b/src/gausskernel/process/tcop/utility.cpp @@ -2716,7 +2716,7 @@ void standard_ProcessUtility(processutility_context* processutility_cxt, if (SS_STANDBY_MODE_WITH_REMOTE_EXECUTE) { ClearTxnInfoForSSLibpqsw(); - if (libpqsw_get_transaction()) { + if (libpqsw_get_transaction() && !libpqsw_is_end()) { libpqsw_set_transaction(false); } } @@ -2829,7 +2829,7 @@ void standard_ProcessUtility(processutility_context* processutility_cxt, if (SS_STANDBY_MODE_WITH_REMOTE_EXECUTE) { ClearTxnInfoForSSLibpqsw(); - if (libpqsw_get_transaction()) { + if (libpqsw_get_transaction() && !libpqsw_is_end()) { libpqsw_set_transaction(false); } } diff --git a/src/gausskernel/storage/access/transam/xact.cpp b/src/gausskernel/storage/access/transam/xact.cpp index 83f7f0a9e..57bcd4ea5 100755 --- a/src/gausskernel/storage/access/transam/xact.cpp +++ b/src/gausskernel/storage/access/transam/xact.cpp @@ -4022,7 +4022,7 @@ static void AbortTransaction(bool PerfectRollback, bool STP_rollback) } #endif - if (SS_STANDBY_MODE_WITH_REMOTE_EXECUTE) { + if (SS_STANDBY_MODE_WITH_REMOTE_EXECUTE && !libpqsw_is_end()) { libpqsw_disconnect(); } diff --git a/src/gausskernel/storage/replication/libpqsw.cpp b/src/gausskernel/storage/replication/libpqsw.cpp index 8d138e48f..697a5d136 100644 --- a/src/gausskernel/storage/replication/libpqsw.cpp +++ b/src/gausskernel/storage/replication/libpqsw.cpp @@ -412,7 +412,7 @@ static bool libpqsw_before_redirect(const char* commandTag, List* query_list, co libpqsw_check_savepoint(query_list, &(redirect_manager->state.have_savepoint)); libpqsw_set_transaction(true); need_redirect = true; - } else if (libpqsw_redirect() || libpqsw_end_command(commandTag)) { + } else if (libpqsw_redirect()) { need_redirect = true; } else { if (strcmp(commandTag, "SET") == 0) { @@ -931,7 +931,7 @@ bool libpqsw_only_localrun() */ bool libpqsw_process_message(int qtype, StringInfo msg) { - if (IsAbortedTransactionBlockState()) { + if (IsAbortedTransactionBlockState() || u_sess->proc_cxt.clientIsCMAgent) { return false; }