|
22 | 22 | * If the server is shut down, postmaster sends us SIGUSR2 after all
|
23 | 23 | * regular backends have exited and the shutdown checkpoint has been written.
|
24 | 24 | * This instruct walsender to send any outstanding WAL, including the
|
25 |
| - * shutdown checkpoint record, and then exit. |
| 25 | + * shutdown checkpoint record, wait for it to be replicated to the standby, |
| 26 | + * and then exit. |
26 | 27 | *
|
27 | 28 | *
|
28 | 29 | * Portions Copyright (c) 2010-2011, PostgreSQL Global Development Group
|
@@ -767,15 +768,17 @@ WalSndLoop(void)
|
767 | 768 |
|
768 | 769 | /*
|
769 | 770 | * When SIGUSR2 arrives, we send any outstanding logs up to the
|
770 |
| - * shutdown checkpoint record (i.e., the latest record) and exit. |
| 771 | + * shutdown checkpoint record (i.e., the latest record), wait |
| 772 | + * for them to be replicated to the standby, and exit. |
771 | 773 | * This may be a normal termination at shutdown, or a promotion,
|
772 | 774 | * the walsender is not sure which.
|
773 | 775 | */
|
774 | 776 | if (walsender_ready_to_stop)
|
775 | 777 | {
|
776 | 778 | /* ... let's just be real sure we're caught up ... */
|
777 | 779 | XLogSend(output_message, &caughtup);
|
778 |
| - if (caughtup && !pq_is_send_pending()) |
| 780 | + if (caughtup && XLByteEQ(sentPtr, MyWalSnd->flush) && |
| 781 | + !pq_is_send_pending()) |
779 | 782 | {
|
780 | 783 | walsender_shutdown_requested = true;
|
781 | 784 | continue; /* don't want to wait more */
|
|
0 commit comments