@@ -682,7 +682,7 @@ typedef struct XLogCtlData
682
682
* WAL replay, if it is waiting for WAL to arrive or failover trigger file
683
683
* to appear.
684
684
*/
685
- Latch recoveryWakeupLatch ;
685
+ Latch * recoveryWakeupLatch ;
686
686
687
687
/*
688
688
* During recovery, we keep a copy of the latest checkpoint record here.
@@ -5185,7 +5185,6 @@ XLOGShmemInit(void)
5185
5185
SpinLockInit (& XLogCtl -> Insert .insertpos_lck );
5186
5186
SpinLockInit (& XLogCtl -> info_lck );
5187
5187
SpinLockInit (& XLogCtl -> ulsn_lck );
5188
- InitSharedLatch (& XLogCtl -> recoveryWakeupLatch );
5189
5188
}
5190
5189
5191
5190
/*
@@ -6122,7 +6121,7 @@ recoveryApplyDelay(XLogReaderState *record)
6122
6121
6123
6122
while (true)
6124
6123
{
6125
- ResetLatch (& XLogCtl -> recoveryWakeupLatch );
6124
+ ResetLatch (MyLatch );
6126
6125
6127
6126
/* might change the trigger file's location */
6128
6127
HandleStartupProcInterrupts ();
@@ -6146,7 +6145,7 @@ recoveryApplyDelay(XLogReaderState *record)
6146
6145
elog (DEBUG2 , "recovery apply delay %ld seconds, %d milliseconds" ,
6147
6146
secs , microsecs / 1000 );
6148
6147
6149
- (void ) WaitLatch (& XLogCtl -> recoveryWakeupLatch ,
6148
+ (void ) WaitLatch (MyLatch ,
6150
6149
WL_LATCH_SET | WL_TIMEOUT | WL_EXIT_ON_PM_DEATH ,
6151
6150
secs * 1000L + microsecs / 1000 ,
6152
6151
WAIT_EVENT_RECOVERY_APPLY_DELAY );
@@ -6474,11 +6473,11 @@ StartupXLOG(void)
6474
6473
}
6475
6474
6476
6475
/*
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.
6479
6478
*/
6480
6479
if (ArchiveRecoveryRequested )
6481
- OwnLatch ( & XLogCtl -> recoveryWakeupLatch ) ;
6480
+ XLogCtl -> recoveryWakeupLatch = & MyProc -> procLatch ;
6482
6481
6483
6482
/* Set up XLOG reader facility */
6484
6483
MemSet (& private , 0 , sizeof (XLogPageReadPrivate ));
@@ -7489,11 +7488,11 @@ StartupXLOG(void)
7489
7488
ResetUnloggedRelations (UNLOGGED_RELATION_INIT );
7490
7489
7491
7490
/*
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.
7494
7493
*/
7495
7494
if (ArchiveRecoveryRequested )
7496
- DisownLatch ( & XLogCtl -> recoveryWakeupLatch ) ;
7495
+ XLogCtl -> recoveryWakeupLatch = NULL ;
7497
7496
7498
7497
/*
7499
7498
* We are now done reading the xlog from stream. Turn off streaming
@@ -12242,12 +12241,12 @@ WaitForWALToBecomeAvailable(XLogRecPtr RecPtr, bool randAccess,
12242
12241
wait_time = wal_retrieve_retry_interval -
12243
12242
(secs * 1000 + usecs / 1000 );
12244
12243
12245
- (void ) WaitLatch (& XLogCtl -> recoveryWakeupLatch ,
12244
+ (void ) WaitLatch (MyLatch ,
12246
12245
WL_LATCH_SET | WL_TIMEOUT |
12247
12246
WL_EXIT_ON_PM_DEATH ,
12248
12247
wait_time ,
12249
12248
WAIT_EVENT_RECOVERY_RETRIEVE_RETRY_INTERVAL );
12250
- ResetLatch (& XLogCtl -> recoveryWakeupLatch );
12249
+ ResetLatch (MyLatch );
12251
12250
now = GetCurrentTimestamp ();
12252
12251
}
12253
12252
last_fail_time = now ;
@@ -12498,11 +12497,11 @@ WaitForWALToBecomeAvailable(XLogRecPtr RecPtr, bool randAccess,
12498
12497
* to react to a trigger file promptly and to check if the
12499
12498
* WAL receiver is still active.
12500
12499
*/
12501
- (void ) WaitLatch (& XLogCtl -> recoveryWakeupLatch ,
12500
+ (void ) WaitLatch (MyLatch ,
12502
12501
WL_LATCH_SET | WL_TIMEOUT |
12503
12502
WL_EXIT_ON_PM_DEATH ,
12504
12503
5000L , WAIT_EVENT_RECOVERY_WAL_STREAM );
12505
- ResetLatch (& XLogCtl -> recoveryWakeupLatch );
12504
+ ResetLatch (MyLatch );
12506
12505
break ;
12507
12506
}
12508
12507
@@ -12674,7 +12673,7 @@ CheckPromoteSignal(void)
12674
12673
void
12675
12674
WakeupRecovery (void )
12676
12675
{
12677
- SetLatch (& XLogCtl -> recoveryWakeupLatch );
12676
+ SetLatch (XLogCtl -> recoveryWakeupLatch );
12678
12677
}
12679
12678
12680
12679
/*
0 commit comments