diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index 754dfe7..65de487 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -5008,6 +5008,12 @@ recoveryStopsHere(XLogRecord *record, bool *includeThis)
 static void
 recoveryPausesHere(void)
 {
+	/*
+	 * Pause only if users can connect to send a resume message
+	 */
+	if (!LocalHotStandbyActive)
+		return;
+
 	ereport(LOG,
 			(errmsg("recovery has paused"),
 			 errhint("Execute pg_xlog_replay_resume() to continue.")));
@@ -5783,10 +5789,11 @@ StartupXLOG(void)
 				if (recoveryStopsHere(record, &recoveryApply))
 				{
 					/*
-					 * Pause only if users can connect to send a resume
-					 * message
+					 * We've reached stop point, but not yet applied last
+					 * record. Pause BEFORE final apply, if requested, but
+					 * only if users can connect to send a resume message
 					 */
-					if (recoveryPauseAtTarget && standbyState == STANDBY_SNAPSHOT_READY)
+					if (recoveryPauseAtTarget && !recoveryApply)
 					{
 						SetRecoveryPause(true);
 						recoveryPausesHere();
@@ -5820,28 +5827,26 @@ StartupXLOG(void)
 				}
 
 				/*
+				 * If we are attempting to enter Hot Standby mode, check
+				 * for pauses and process incoming transactionids.
+				 */
+				if (standbyState >= STANDBY_INITIALIZED)
+				{
+					if (recoveryPause)
+						recoveryPausesHere();
+
+					if (TransactionIdIsValid(record->xl_xid))
+						RecordKnownAssignedTransactionIds(record->xl_xid);
+				}
+
+				/*
 				 * Update shared replayEndRecPtr before replaying this record,
 				 * so that XLogFlush will update minRecoveryPoint correctly.
 				 */
 				SpinLockAcquire(&xlogctl->info_lck);
 				xlogctl->replayEndRecPtr = EndRecPtr;
-				recoveryPause = xlogctl->recoveryPause;
 				SpinLockRelease(&xlogctl->info_lck);
 
-				/*
-				 * Pause only if users can connect to send a resume message
-				 */
-				if (recoveryPause && standbyState == STANDBY_SNAPSHOT_READY)
-					recoveryPausesHere();
-
-				/*
-				 * If we are attempting to enter Hot Standby mode, process
-				 * XIDs we see
-				 */
-				if (standbyState >= STANDBY_INITIALIZED &&
-					TransactionIdIsValid(record->xl_xid))
-					RecordKnownAssignedTransactionIds(record->xl_xid);
-
 				/* Now apply the WAL record itself */
 				RmgrTable[record->xl_rmid].rm_redo(EndRecPtr, record);
 
@@ -5875,6 +5880,7 @@ StartupXLOG(void)
 				 */
 				SpinLockAcquire(&xlogctl->info_lck);
 				xlogctl->recoveryLastRecPtr = EndRecPtr;
+				recoveryPause = xlogctl->recoveryPause;
 				SpinLockRelease(&xlogctl->info_lck);
 
 				LastRec = ReadRecPtr;
@@ -5883,6 +5889,17 @@ StartupXLOG(void)
 			} while (record != NULL && recoveryContinue);
 
 			/*
+			 * We've reached stop point, but not yet applied last
+			 * record. Pause AFTER final apply, if requested, but
+			 * only if users can connect to send a resume message
+			 */
+			if (reachedStopPoint && recoveryPauseAtTarget && recoveryApply)
+			{
+				SetRecoveryPause(true);
+				recoveryPausesHere();
+			}
+
+			/*
 			 * end of main redo apply loop
 			 */
 
