diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index 7397b6e..6e2617d 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -12271,10 +12271,17 @@ WaitForWALToBecomeAvailable(XLogRecPtr RecPtr, bool randAccess,
 					 * Wait for more WAL to arrive. Time out after 5 seconds
 					 * to react to a trigger file promptly.
 					 */
-					(void) WaitLatch(&XLogCtl->recoveryWakeupLatch,
-									 WL_LATCH_SET | WL_TIMEOUT |
-									 WL_EXIT_ON_PM_DEATH,
-									 5000L, WAIT_EVENT_RECOVERY_WAL_ALL);
+					if (TriggerFile == NULL) 
+						(void) WaitLatch(&XLogCtl->recoveryWakeupLatch,
+										 WL_LATCH_SET | 
+										 WL_EXIT_ON_PM_DEATH,
+										 0, WAIT_EVENT_RECOVERY_WAL_ALL);
+					else
+						(void) WaitLatch(&XLogCtl->recoveryWakeupLatch,
+										 WL_LATCH_SET | WL_TIMEOUT |
+										 WL_EXIT_ON_PM_DEATH,
+										 5000L, WAIT_EVENT_RECOVERY_WAL_ALL);
+
 					ResetLatch(&XLogCtl->recoveryWakeupLatch);
 					break;
 				}
