diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c index a39f373fa15..b671c434a3e 100644 --- a/src/backend/replication/walsender.c +++ b/src/backend/replication/walsender.c @@ -2488,13 +2488,14 @@ WalSndDone(WalSndSendDataCallback send_data) send_data(); /* - * 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. + * To figure out whether all WAL has successfully been replicated, check + * flush location if valid, write otherwise. Tools like pg_receivexlog + * will usually (unless in synchronous mode) return an invalid flush + * location. */ replicatedPtr = XLogRecPtrIsInvalid(MyWalSnd->flush) ? MyWalSnd->write : MyWalSnd->flush; + if (WalSndCaughtUp && sentPtr == replicatedPtr && !pq_is_send_pending()) { @@ -2505,7 +2506,10 @@ WalSndDone(WalSndSendDataCallback send_data) proc_exit(0); } if (!waiting_for_ping_response) + { WalSndKeepalive(true); + waiting_for_ping_response = true; + } } /*