@@ -95,7 +95,6 @@ int recovery_min_apply_delay = 0;
9595/* options formerly taken from recovery.conf for XLOG streaming */
9696char * PrimaryConnInfo = NULL ;
9797char * PrimarySlotName = NULL ;
98- char * PromoteTriggerFile = NULL ;
9998bool wal_receiver_create_temp_slot = false;
10099
101100/*
@@ -318,8 +317,8 @@ typedef struct XLogRecoveryCtlData
318317
319318 /*
320319 * recoveryWakeupLatch is used to wake up the startup process to continue
321- * WAL replay, if it is waiting for WAL to arrive or failover trigger file
322- * to appear .
320+ * WAL replay, if it is waiting for WAL to arrive or promotion to be
321+ * requested .
323322 *
324323 * Note that the startup process also uses another latch, its procLatch,
325324 * to wait for recovery conflict. If we get rid of recoveryWakeupLatch for
@@ -2906,10 +2905,7 @@ recoveryApplyDelay(XLogReaderState *record)
29062905 {
29072906 ResetLatch (& XLogRecoveryCtl -> recoveryWakeupLatch );
29082907
2909- /*
2910- * This might change recovery_min_apply_delay or the trigger file's
2911- * location.
2912- */
2908+ /* This might change recovery_min_apply_delay. */
29132909 HandleStartupProcInterrupts ();
29142910
29152911 if (CheckForStandbyTrigger ())
@@ -3155,8 +3151,8 @@ ReadRecord(XLogPrefetcher *xlogprefetcher, int emode,
31553151 * as for waiting for the requested WAL record to arrive in standby mode.
31563152 *
31573153 * 'emode' specifies the log level used for reporting "file not found" or
3158- * "end of WAL" situations in archive recovery, or in standby mode when a
3159- * trigger file is found . If set to WARNING or below, XLogPageRead() returns
3154+ * "end of WAL" situations in archive recovery, or in standby mode when
3155+ * promotion is triggered . If set to WARNING or below, XLogPageRead() returns
31603156 * XLREAD_FAIL in those situations, on higher log levels the ereport() won't
31613157 * return.
31623158 *
@@ -3424,7 +3420,7 @@ WaitForWALToBecomeAvailable(XLogRecPtr RecPtr, bool randAccess,
34243420 *
34253421 * 1. Read from either archive or pg_wal (XLOG_FROM_ARCHIVE), or just
34263422 * pg_wal (XLOG_FROM_PG_WAL)
3427- * 2. Check trigger file
3423+ * 2. Check for promotion trigger request
34283424 * 3. Read from primary server via walreceiver (XLOG_FROM_STREAM)
34293425 * 4. Rescan timelines
34303426 * 5. Sleep wal_retrieve_retry_interval milliseconds, and loop back to 1.
@@ -3481,10 +3477,10 @@ WaitForWALToBecomeAvailable(XLogRecPtr RecPtr, bool randAccess,
34813477 case XLOG_FROM_PG_WAL :
34823478
34833479 /*
3484- * Check to see if the trigger file exists . Note that we
3485- * do this only after failure, so when you create the
3486- * trigger file, we still finish replaying as much as we
3487- * can from archive and pg_wal before failover.
3480+ * Check to see if promotion is requested . Note that we do
3481+ * this only after failure, so when you promote, we still
3482+ * finish replaying as much as we can from archive and
3483+ * pg_wal before failover.
34883484 */
34893485 if (StandbyMode && CheckForStandbyTrigger ())
34903486 {
@@ -3840,14 +3836,13 @@ WaitForWALToBecomeAvailable(XLogRecPtr RecPtr, bool randAccess,
38403836 XLogPrefetcherComputeStats (xlogprefetcher );
38413837
38423838 /*
3843- * Wait for more WAL to arrive. Time out after 5 seconds
3844- * to react to a trigger file promptly and to check if the
3845- * WAL receiver is still active.
3839+ * Wait for more WAL to arrive, when we will be woken
3840+ * immediately by the WAL receiver.
38463841 */
38473842 (void ) WaitLatch (& XLogRecoveryCtl -> recoveryWakeupLatch ,
3848- WL_LATCH_SET | WL_TIMEOUT |
3849- WL_EXIT_ON_PM_DEATH ,
3850- 5000L , WAIT_EVENT_RECOVERY_WAL_STREAM );
3843+ WL_LATCH_SET | WL_EXIT_ON_PM_DEATH ,
3844+ -1L ,
3845+ WAIT_EVENT_RECOVERY_WAL_STREAM );
38513846 ResetLatch (& XLogRecoveryCtl -> recoveryWakeupLatch );
38523847 break ;
38533848 }
@@ -4294,14 +4289,11 @@ SetPromoteIsTriggered(void)
42944289}
42954290
42964291/*
4297- * Check to see whether the user-specified trigger file exists and whether a
4298- * promote request has arrived. If either condition holds, return true.
4292+ * Check whether a promote request has arrived.
42994293 */
43004294static bool
43014295CheckForStandbyTrigger (void )
43024296{
4303- struct stat stat_buf ;
4304-
43054297 if (LocalPromoteIsTriggered )
43064298 return true;
43074299
@@ -4314,23 +4306,6 @@ CheckForStandbyTrigger(void)
43144306 return true;
43154307 }
43164308
4317- if (PromoteTriggerFile == NULL || strcmp (PromoteTriggerFile , "" ) == 0 )
4318- return false;
4319-
4320- if (stat (PromoteTriggerFile , & stat_buf ) == 0 )
4321- {
4322- ereport (LOG ,
4323- (errmsg ("promote trigger file found: %s" , PromoteTriggerFile )));
4324- unlink (PromoteTriggerFile );
4325- SetPromoteIsTriggered ();
4326- return true;
4327- }
4328- else if (errno != ENOENT )
4329- ereport (ERROR ,
4330- (errcode_for_file_access (),
4331- errmsg ("could not stat promote trigger file \"%s\": %m" ,
4332- PromoteTriggerFile )));
4333-
43344309 return false;
43354310}
43364311
0 commit comments