diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index a76aef3..fbc2d2f 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -6835,6 +6835,14 @@ StartupXLOG(void)
 					recoveryApplyDelay();
 
 					/*
+					 * Check for standby trigger to prevent the
+					 * replay of undesired WAL records if the
+					 * slave was promoted during the delay.
+					 */
+					if (CheckForStandbyTrigger())
+						break;
+
+					/*
 					 * We test for paused recovery again here. If
 					 * user sets delayed apply, it may be because
 					 * they expect to pause recovery in case of
