|
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-2012, PostgreSQL Global Development Group
|
@@ -800,15 +801,17 @@ WalSndLoop(void)
|
800 | 801 |
|
801 | 802 | /*
|
802 | 803 | * When SIGUSR2 arrives, we send any outstanding logs up to the
|
803 |
| - * shutdown checkpoint record (i.e., the latest record) and exit. |
| 804 | + * shutdown checkpoint record (i.e., the latest record), wait |
| 805 | + * for them to be replicated to the standby, and exit. |
804 | 806 | * This may be a normal termination at shutdown, or a promotion,
|
805 | 807 | * the walsender is not sure which.
|
806 | 808 | */
|
807 | 809 | if (walsender_ready_to_stop)
|
808 | 810 | {
|
809 | 811 | /* ... let's just be real sure we're caught up ... */
|
810 | 812 | XLogSend(output_message, &caughtup);
|
811 |
| - if (caughtup && !pq_is_send_pending()) |
| 813 | + if (caughtup && XLByteEQ(sentPtr, MyWalSnd->flush) && |
| 814 | + !pq_is_send_pending()) |
812 | 815 | {
|
813 | 816 | walsender_shutdown_requested = true;
|
814 | 817 | continue; /* don't want to wait more */
|
|
0 commit comments