Skip to content

Commit 65e8dbb

Browse files
committed
Fix bug in clean shutdown of walsender that pg_receiving is connecting to.
On clean shutdown, walsender waits for all WAL to be replicated to a standby, and exits. It determined whether that replication had been completed by checking whether its sent location had been equal to a standby's flush location. Unfortunately this condition never becomes true when the standby such as pg_receivexlog which always returns an invalid flush location is connecting to walsender, and then walsender waits forever. This commit changes walsender so that it just checks a standby's write location if a flush location is invalid. Back-patch to 9.1 where enough infrastructure for this exists.
1 parent f84997c commit 65e8dbb

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/backend/replication/walsender.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -775,9 +775,20 @@ WalSndLoop(void)
775775
*/
776776
if (walsender_ready_to_stop)
777777
{
778+
XLogRecPtr replicatedPtr;
779+
778780
/* ... let's just be real sure we're caught up ... */
779781
XLogSend(output_message, &caughtup);
780-
if (caughtup && XLByteEQ(sentPtr, MyWalSnd->flush) &&
782+
783+
/*
784+
* Check a write location to see whether all the WAL have
785+
* successfully been replicated if this walsender is connecting
786+
* to a standby such as pg_receivexlog which always returns
787+
* an invalid flush location. Otherwise, check a flush location.
788+
*/
789+
replicatedPtr = XLogRecPtrIsInvalid(MyWalSnd->flush) ?
790+
MyWalSnd->write : MyWalSnd->flush;
791+
if (caughtup && XLByteEQ(sentPtr, replicatedPtr) &&
781792
!pq_is_send_pending())
782793
{
783794
walsender_shutdown_requested = true;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy