*** a/src/backend/replication/walsender.c
--- b/src/backend/replication/walsender.c
***************
*** 2449,2455 **** WalSndDone(WalSndSendDataCallback send_data)
  	/* ... let's just be real sure we're caught up ... */
  	send_data();
  
! 	if (WalSndCaughtUp && sentPtr == MyWalSnd->flush &&
  		!pq_is_send_pending())
  	{
  		/* Inform the standby that XLOG streaming is done */
--- 2449,2464 ----
  	/* ... let's just be real sure we're caught up ... */
  	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 basically returns
! 	 * an invalid flush location. Otherwise, check a flush location.
! 	 */
! 	if (WalSndCaughtUp &&
! 		(sentPtr == MyWalSnd->flush ||
! 		 (XLogRecPtrIsInvalid(MyWalSnd->flush) &&
! 		  sentPtr == MyWalSnd->write)) &&
  		!pq_is_send_pending())
  	{
  		/* Inform the standby that XLOG streaming is done */
