diff --git a/src/gausskernel/storage/replication/syncrep.cpp b/src/gausskernel/storage/replication/syncrep.cpp index a5503c84432937a3ef1bdcf83ff667915ccba8dd..446f065564e551f3ad3cd6cd80dfc22b3e652c43 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