summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFujii Masao2014-03-17 11:37:50 +0000
committerFujii Masao2014-03-17 11:37:50 +0000
commit5c6d9fc4b2b8b6688a482a4b4116d7642e36b9d9 (patch)
tree0c8feb9bedd77f15cc5f83764dd502d504647c20
parent02703ff2277791a7f1bccf61124bee830f2b5fcb (diff)
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.
-rw-r--r--src/backend/replication/walsender.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c
index 09854112062..6e22c03bcfa 100644
--- a/src/backend/replication/walsender.c
+++ b/src/backend/replication/walsender.c
@@ -2446,10 +2446,20 @@ XLogSendLogical(void)
static void
WalSndDone(WalSndSendDataCallback send_data)
{
+ XLogRecPtr replicatedPtr;
+
/* ... let's just be real sure we're caught up ... */
send_data();
- if (WalSndCaughtUp && sentPtr == MyWalSnd->flush &&
+ /*
+ * Check a write location to see whether all the WAL have
+ * successfully been replicated if this walsender is connecting
+ * to a standby such as pg_receivexlog which always returns
+ * an invalid flush location. Otherwise, check a flush location.
+ */
+ replicatedPtr = XLogRecPtrIsInvalid(MyWalSnd->flush) ?
+ MyWalSnd->write : MyWalSnd->flush;
+ if (WalSndCaughtUp && sentPtr == replicatedPtr &&
!pq_is_send_pending())
{
/* Inform the standby that XLOG streaming is done */