From 25f5bd221a683ea93f4c19fdfc03924a9492984a Mon Sep 17 00:00:00 2001
From: Thomas Munro <tmunro@postgresql.org>
Date: Wed, 16 Nov 2022 16:00:07 +1300
Subject: [PATCH] Fix slowdown in TAP tests due to recent walreceiver change.

Commit 05a7be93 changed the timing of the first reply sent by a
walreceiver, which caused some TAP tests to wait in wait_for_catchup for
~10 seconds (wal_receiver_status_interval).  Fix by sending an initial
reply message immediately, and do the same for HS for consistency.

Author: Nathan Bossart <nathandbossart@gmail.com>
Discussion: https://postgr.es/m/742545.1668377284%40sss.pgh.pa.us
---
 src/backend/replication/walreceiver.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/backend/replication/walreceiver.c b/src/backend/replication/walreceiver.c
index 8bd2ba37dd..87ee6b948c 100644
--- a/src/backend/replication/walreceiver.c
+++ b/src/backend/replication/walreceiver.c
@@ -433,6 +433,11 @@ WalReceiverMain(void)
 			for (int i = 0; i < NUM_WALRCV_WAKEUPS; ++i)
 				WalRcvComputeNextWakeup(i, now);
 
+			/* Send initial reply/feedback messages. */
+			if (wal_receiver_status_interval > 0)
+				XLogWalRcvSendReply(true, false);
+			XLogWalRcvSendHSFeedback(true);
+
 			/* Loop until end-of-streaming or error */
 			for (;;)
 			{
-- 
2.35.1

