diff --git a/src/backend/access/transam/xlogfuncs.c b/src/backend/access/transam/xlogfuncs.c
index 4795c6fa94..931305abc6 100644
*** a/src/backend/access/transam/xlogfuncs.c
--- b/src/backend/access/transam/xlogfuncs.c
***************
*** 759,764 **** pg_promote(PG_FUNCTION_ARGS)
--- 759,766 ----
  #define WAITS_PER_SECOND 10
  	for (i = 0; i < WAITS_PER_SECOND * wait_seconds; i++)
  	{
+ 		int			rc;
+ 
  		ResetLatch(MyLatch);
  
  		if (!RecoveryInProgress())
***************
*** 766,778 **** pg_promote(PG_FUNCTION_ARGS)
  
  		CHECK_FOR_INTERRUPTS();
  
! 		(void) WaitLatch(MyLatch,
! 						 WL_LATCH_SET | WL_TIMEOUT | WL_POSTMASTER_DEATH,
! 						 1000L / WAITS_PER_SECOND,
! 						 WAIT_EVENT_PROMOTE);
  	}
  
! 	ereport(WARNING,
! 			(errmsg("server did not promote within %d seconds", wait_seconds)));
  	PG_RETURN_BOOL(false);
  }
--- 768,788 ----
  
  		CHECK_FOR_INTERRUPTS();
  
! 		rc = WaitLatch(MyLatch,
! 					   WL_LATCH_SET | WL_TIMEOUT | WL_POSTMASTER_DEATH,
! 					   1000L / WAITS_PER_SECOND,
! 					   WAIT_EVENT_PROMOTE);
! 
! 		/*
! 		 * Emergency bailout if postmaster has died.  This is to avoid the
! 		 * necessity for manual cleanup of all postmaster children.
! 		 */
! 		if (rc & WL_POSTMASTER_DEATH)
! 			break;
  	}
  
! 	if (i >= WAITS_PER_SECOND * wait_seconds)
! 		ereport(WARNING,
! 				(errmsg("server did not promote within %d seconds", wait_seconds)));
  	PG_RETURN_BOOL(false);
  }
