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

Commit 3857234

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 6082907 commit 3857234

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
@@ -1053,9 +1053,20 @@ WalSndLoop(void)
10531053
*/
10541054
if (walsender_ready_to_stop)
10551055
{
1056+
XLogRecPtr replicatedPtr;
1057+
10561058
/* ... let's just be real sure we're caught up ... */
10571059
XLogSend(&caughtup);
1058-
if (caughtup && sentPtr == MyWalSnd->flush &&
1060+
1061+
/*
1062+
* Check a write location to see whether all the WAL have
1063+
* successfully been replicated if this walsender is connecting
1064+
* to a standby such as pg_receivexlog which always returns
1065+
* an invalid flush location. Otherwise, check a flush location.
1066+
*/
1067+
replicatedPtr = XLogRecPtrIsInvalid(MyWalSnd->flush) ?
1068+
MyWalSnd->write : MyWalSnd->flush;
1069+
if (caughtup && sentPtr == replicatedPtr &&
10591070
!pq_is_send_pending())
10601071
{
10611072
/* Inform the standby that XLOG streaming is done */

0 commit comments

Comments
 (0)