Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 5c6d9fc

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 02703ff commit 5c6d9fc

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/backend/replication/walsender.c

+11-1
Original file line numberDiff line numberDiff line change
@@ -2446,10 +2446,20 @@ XLogSendLogical(void)
24462446
static void
24472447
WalSndDone(WalSndSendDataCallback send_data)
24482448
{
2449+
XLogRecPtr replicatedPtr;
2450+
24492451
/* ... let's just be real sure we're caught up ... */
24502452
send_data();
24512453

2452-
if (WalSndCaughtUp && sentPtr == MyWalSnd->flush &&
2454+
/*
2455+
* Check a write location to see whether all the WAL have
2456+
* successfully been replicated if this walsender is connecting
2457+
* to a standby such as pg_receivexlog which always returns
2458+
* an invalid flush location. Otherwise, check a flush location.
2459+
*/
2460+
replicatedPtr = XLogRecPtrIsInvalid(MyWalSnd->flush) ?
2461+
MyWalSnd->write : MyWalSnd->flush;
2462+
if (WalSndCaughtUp && sentPtr == replicatedPtr &&
24532463
!pq_is_send_pending())
24542464
{
24552465
/* Inform the standby that XLOG streaming is done */

0 commit comments

Comments
 (0)