From 48193b6c3966d7c0630273e54c51e1423e4b28ff Mon Sep 17 00:00:00 2001 From: justbk <249396768@qq.com> Date: Mon, 30 Jan 2023 16:47:59 +0800 Subject: [PATCH] [libpqsw]repair invalid username when enable thread pool --- src/gausskernel/storage/replication/libpqsw.cpp | 7 +++++-- src/include/replication/libpqsw.h | 5 +++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/gausskernel/storage/replication/libpqsw.cpp b/src/gausskernel/storage/replication/libpqsw.cpp index 95510ea8f..1e1c9d909 100644 --- a/src/gausskernel/storage/replication/libpqsw.cpp +++ b/src/gausskernel/storage/replication/libpqsw.cpp @@ -410,10 +410,12 @@ static void libpqsw_inner_excute_pbe(bool waitResult, bool updateFlag) RedirectMessage* redirect_msg = (RedirectMessage*)lfirst(message); const StringInfo pbe_send_message = message_manager->get_merge_message(redirect_msg); redirect_msg->cur_pos = 0; + const char* db_name = u_sess->proc_cxt.MyProcPort->database_name; + const char* username = u_sess->proc_cxt.MyProcPort->user_name; (void)libpqsw_remote_excute_sql(0, pbe_send_message->data, pbe_send_message->len, - t_thrd.proc_cxt.PostInit->m_indbname, - t_thrd.proc_cxt.PostInit->m_username, + db_name, + username, redirect_msg->commandTag, waitResult, redirect_msg->type == RT_NORMAL); @@ -663,6 +665,7 @@ void libpqsw_disconnect(void) { PQfinish(t_thrd.libsw_cxt.streamConn); t_thrd.libsw_cxt.streamConn = NULL; + get_redirect_manager()->init(); } // parse primary results. diff --git a/src/include/replication/libpqsw.h b/src/include/replication/libpqsw.h index 624734c25..abd1129de 100644 --- a/src/include/replication/libpqsw.h +++ b/src/include/replication/libpqsw.h @@ -191,6 +191,11 @@ public: RedirectManager() { log_trace_msg = makeStringInfo(); + init(); + } + + void init() + { state.transaction = false; state.enable_remote_excute = false; state.redirect = false;