From d27d38c5b58ebb4bb10a70279771cdd59aeff703 Mon Sep 17 00:00:00 2001 From: cchen676 Date: Mon, 7 Apr 2025 16:13:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=BC=80=E5=90=AF=E5=A4=87?= =?UTF-8?q?=E6=9C=BA=E9=80=BB=E8=BE=91=E5=A4=8D=E5=88=B6=EF=BC=8C=E6=89=A7?= =?UTF-8?q?=E8=A1=8C=E5=80=92=E6=8D=A2=E6=97=B6=E5=A6=82=E6=9E=9C=E5=90=8C?= =?UTF-8?q?=E6=AD=A5=E5=A4=87=E5=85=88=E9=80=80=EF=BC=8C=E4=B8=BB=E6=9C=BA?= =?UTF-8?q?=E7=9A=84=E9=80=BB=E8=BE=91=E5=A4=8D=E5=88=B6walsender=E4=B8=8D?= =?UTF-8?q?=E4=BC=9A=E9=80=80=E5=87=BA=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/gausskernel/storage/replication/syncrep.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/gausskernel/storage/replication/syncrep.cpp b/src/gausskernel/storage/replication/syncrep.cpp index a5503c8443..446f065564 100755 --- a/src/gausskernel/storage/replication/syncrep.cpp +++ b/src/gausskernel/storage/replication/syncrep.cpp @@ -323,6 +323,23 @@ SyncWaitRet SyncRepWaitForLSN(XLogRecPtr XactCommitLSN, bool enableHandleCancel) break; } + /* + * If switchover request happened, a logical walsender may wait for synchronous + * replication as the walsender of synchronous standby quit in advance. We need + * to break the waiting to finish switchover. + */ + if ((NULL != t_thrd.walsender_cxt.MyWalSnd) && u_sess->attr.attr_sql.enable_slot_log && + t_thrd.walsender_cxt.MyWalSnd->node_state == NODESTATE_STANDBY_REDIRECT && + !t_thrd.walsender_cxt.MyWalSnd->replSender) { + ereport(WARNING, + (errmsg("canceling wait for synchronous replication due to switchover " + "request for logical replication."))); + if (SyncRepCancelWait()) { + waitStopRes = STOP_WAIT; + break; + } + } + /* * If a wait for synchronous replication is pending, we can neither * acknowledge the commit nor raise ERROR or FATAL. The latter would -- Gitee