aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/backend/replication/walsender.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c
index 7ccab20b13e..bbde1c32e73 100644
--- a/src/backend/replication/walsender.c
+++ b/src/backend/replication/walsender.c
@@ -22,7 +22,8 @@
* If the server is shut down, postmaster sends us SIGUSR2 after all
* regular backends have exited and the shutdown checkpoint has been written.
* This instruct walsender to send any outstanding WAL, including the
- * shutdown checkpoint record, and then exit.
+ * shutdown checkpoint record, wait for it to be replicated to the standby,
+ * and then exit.
*
*
* Portions Copyright (c) 2010-2011, PostgreSQL Global Development Group
@@ -767,7 +768,8 @@ WalSndLoop(void)
/*
* When SIGUSR2 arrives, we send any outstanding logs up to the
- * shutdown checkpoint record (i.e., the latest record) and exit.
+ * shutdown checkpoint record (i.e., the latest record), wait
+ * for them to be replicated to the standby, and exit.
* This may be a normal termination at shutdown, or a promotion,
* the walsender is not sure which.
*/
@@ -775,7 +777,8 @@ WalSndLoop(void)
{
/* ... let's just be real sure we're caught up ... */
XLogSend(output_message, &caughtup);
- if (caughtup && !pq_is_send_pending())
+ if (caughtup && XLByteEQ(sentPtr, MyWalSnd->flush) &&
+ !pq_is_send_pending())
{
walsender_shutdown_requested = true;
continue; /* don't want to wait more */