@@ -682,7 +682,7 @@ typedef struct XLogCtlData
682682 * WAL replay, if it is waiting for WAL to arrive or failover trigger file
683683 * to appear.
684684 */
685- Latch recoveryWakeupLatch ;
685+ Latch * recoveryWakeupLatch ;
686686
687687 /*
688688 * During recovery, we keep a copy of the latest checkpoint record here.
@@ -5185,7 +5185,6 @@ XLOGShmemInit(void)
51855185 SpinLockInit (& XLogCtl -> Insert .insertpos_lck );
51865186 SpinLockInit (& XLogCtl -> info_lck );
51875187 SpinLockInit (& XLogCtl -> ulsn_lck );
5188- InitSharedLatch (& XLogCtl -> recoveryWakeupLatch );
51895188}
51905189
51915190/*
@@ -6122,7 +6121,7 @@ recoveryApplyDelay(XLogReaderState *record)
61226121
61236122 while (true)
61246123 {
6125- ResetLatch (& XLogCtl -> recoveryWakeupLatch );
6124+ ResetLatch (MyLatch );
61266125
61276126 /* might change the trigger file's location */
61286127 HandleStartupProcInterrupts ();
@@ -6146,7 +6145,7 @@ recoveryApplyDelay(XLogReaderState *record)
61466145 elog (DEBUG2 , "recovery apply delay %ld seconds, %d milliseconds" ,
61476146 secs , microsecs / 1000 );
61486147
6149- (void ) WaitLatch (& XLogCtl -> recoveryWakeupLatch ,
6148+ (void ) WaitLatch (MyLatch ,
61506149 WL_LATCH_SET | WL_TIMEOUT | WL_EXIT_ON_PM_DEATH ,
61516150 secs * 1000L + microsecs / 1000 ,
61526151 WAIT_EVENT_RECOVERY_APPLY_DELAY );
@@ -6474,11 +6473,11 @@ StartupXLOG(void)
64746473 }
64756474
64766475 /*
6477- * Take ownership of the wakeup latch if we're going to sleep during
6478- * recovery.
6476+ * Advertise our latch that other processes can use to wake us up
6477+ * if we're going to sleep during recovery.
64796478 */
64806479 if (ArchiveRecoveryRequested )
6481- OwnLatch ( & XLogCtl -> recoveryWakeupLatch ) ;
6480+ XLogCtl -> recoveryWakeupLatch = & MyProc -> procLatch ;
64826481
64836482 /* Set up XLOG reader facility */
64846483 MemSet (& private , 0 , sizeof (XLogPageReadPrivate ));
@@ -7489,11 +7488,11 @@ StartupXLOG(void)
74897488 ResetUnloggedRelations (UNLOGGED_RELATION_INIT );
74907489
74917490 /*
7492- * We don't need the latch anymore. It's not strictly necessary to disown
7493- * it, but let's do it for the sake of tidiness.
7491+ * We don't need the latch anymore. It's not strictly necessary to reset
7492+ * it to NULL , but let's do it for the sake of tidiness.
74947493 */
74957494 if (ArchiveRecoveryRequested )
7496- DisownLatch ( & XLogCtl -> recoveryWakeupLatch ) ;
7495+ XLogCtl -> recoveryWakeupLatch = NULL ;
74977496
74987497 /*
74997498 * We are now done reading the xlog from stream. Turn off streaming
@@ -12242,12 +12241,12 @@ WaitForWALToBecomeAvailable(XLogRecPtr RecPtr, bool randAccess,
1224212241 wait_time = wal_retrieve_retry_interval -
1224312242 (secs * 1000 + usecs / 1000 );
1224412243
12245- (void ) WaitLatch (& XLogCtl -> recoveryWakeupLatch ,
12244+ (void ) WaitLatch (MyLatch ,
1224612245 WL_LATCH_SET | WL_TIMEOUT |
1224712246 WL_EXIT_ON_PM_DEATH ,
1224812247 wait_time ,
1224912248 WAIT_EVENT_RECOVERY_RETRIEVE_RETRY_INTERVAL );
12250- ResetLatch (& XLogCtl -> recoveryWakeupLatch );
12249+ ResetLatch (MyLatch );
1225112250 now = GetCurrentTimestamp ();
1225212251 }
1225312252 last_fail_time = now ;
@@ -12498,11 +12497,11 @@ WaitForWALToBecomeAvailable(XLogRecPtr RecPtr, bool randAccess,
1249812497 * to react to a trigger file promptly and to check if the
1249912498 * WAL receiver is still active.
1250012499 */
12501- (void ) WaitLatch (& XLogCtl -> recoveryWakeupLatch ,
12500+ (void ) WaitLatch (MyLatch ,
1250212501 WL_LATCH_SET | WL_TIMEOUT |
1250312502 WL_EXIT_ON_PM_DEATH ,
1250412503 5000L , WAIT_EVENT_RECOVERY_WAL_STREAM );
12505- ResetLatch (& XLogCtl -> recoveryWakeupLatch );
12504+ ResetLatch (MyLatch );
1250612505 break ;
1250712506 }
1250812507
@@ -12674,7 +12673,7 @@ CheckPromoteSignal(void)
1267412673void
1267512674WakeupRecovery (void )
1267612675{
12677- SetLatch (& XLogCtl -> recoveryWakeupLatch );
12676+ SetLatch (XLogCtl -> recoveryWakeupLatch );
1267812677}
1267912678
1268012679/*
0 commit comments