WalSndWaitForWal_WalSndCheckShutdownTimeout.patch

application/octet-stream

Filename: WalSndWaitForWal_WalSndCheckShutdownTimeout.patch
Type: application/octet-stream
Part: 0
Message: Re: Exit walsender before confirming remote flush in logical replication

Patch

Same data as JSON: GET /api/v1/attachments/:id/patch the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes. API reference →
Format: unified
File+
src/backend/replication/walsender.c 10 0
diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c
index 5b5592aeba7..ba783694553 100644
--- a/src/backend/replication/walsender.c
+++ b/src/backend/replication/walsender.c
@@ -1992,6 +1992,16 @@ WalSndWaitForWal(XLogRecPtr loc)
 		/* die if timeout was reached */
 		WalSndCheckTimeOut();
 
+		/*
+		 * If a shutdown is in progress and wal_sender_shutdown_timeout has
+		 * expired, terminate the walsender immediately rather than waiting
+		 * indefinitely for the standby to catch up.  This is needed because
+		 * when synchronized_standby_slots is configured and the physical
+		 * standby is not responding, the logical walsender can get stuck in
+		 * this loop waiting for NeedToWaitForStandbys() to return false.
+		 */
+		WalSndCheckShutdownTimeout();
+
 		/* Send keepalive if the time has come */
 		WalSndKeepaliveIfNecessary();