<para>
Standby mode is exited and the server switches to normal operation
- when <command>pg_ctl promote</command> is run,
- <function>pg_promote()</function> is called, or a trigger file is found
- (<varname>promote_trigger_file</varname>). Before failover,
- any WAL immediately available in the archive or in <filename>pg_wal</filename> will be
- restored, but no attempt is made to connect to the primary.
+ when <command>pg_ctl promote</command> is run, or
+ <function>pg_promote()</function> is called. Before failover,
+ any WAL immediately available in the archive or in <filename>pg_wal</filename>
+ will be restored, but no attempt is made to connect to the primary.
</para>
</sect2>
<para>
To trigger failover of a log-shipping standby server, run
- <command>pg_ctl promote</command>, call <function>pg_promote()</function>,
- or create a trigger file with the file name and path specified by the
- <varname>promote_trigger_file</varname>. If you're planning to use
- <command>pg_ctl promote</command> or to call
- <function>pg_promote()</function> to fail over,
- <varname>promote_trigger_file</varname> is not required. If you're
- setting up the reporting servers that are only used to offload read-only
- queries from the primary, not for high availability purposes, you don't
- need to promote it.
+ <command>pg_ctl promote</command> or call <function>pg_promote()</function>.
+ If you're setting up reporting servers that are only used to offload
+ read-only queries from the primary, not for high availability purposes,
+ you don't need to promote.
</para>
</sect1>
/* options formerly taken from recovery.conf for XLOG streaming */
char *PrimaryConnInfo = NULL;
char *PrimarySlotName = NULL;
-char *PromoteTriggerFile = NULL;
bool wal_receiver_create_temp_slot = false;
/*
/*
* recoveryWakeupLatch is used to wake up the startup process to continue
- * WAL replay, if it is waiting for WAL to arrive or failover trigger file
- * to appear.
+ * WAL replay, if it is waiting for WAL to arrive or promotion to be
+ * requested.
*
* Note that the startup process also uses another latch, its procLatch,
* to wait for recovery conflict. If we get rid of recoveryWakeupLatch for
{
ResetLatch(&XLogRecoveryCtl->recoveryWakeupLatch);
- /*
- * This might change recovery_min_apply_delay or the trigger file's
- * location.
- */
+ /* This might change recovery_min_apply_delay. */
HandleStartupProcInterrupts();
if (CheckForStandbyTrigger())
* as for waiting for the requested WAL record to arrive in standby mode.
*
* 'emode' specifies the log level used for reporting "file not found" or
- * "end of WAL" situations in archive recovery, or in standby mode when a
- * trigger file is found. If set to WARNING or below, XLogPageRead() returns
+ * "end of WAL" situations in archive recovery, or in standby mode when
+ * promotion is triggered. If set to WARNING or below, XLogPageRead() returns
* XLREAD_FAIL in those situations, on higher log levels the ereport() won't
* return.
*
*
* 1. Read from either archive or pg_wal (XLOG_FROM_ARCHIVE), or just
* pg_wal (XLOG_FROM_PG_WAL)
- * 2. Check trigger file
+ * 2. Check for promotion trigger request
* 3. Read from primary server via walreceiver (XLOG_FROM_STREAM)
* 4. Rescan timelines
* 5. Sleep wal_retrieve_retry_interval milliseconds, and loop back to 1.
case XLOG_FROM_PG_WAL:
/*
- * Check to see if the trigger file exists. Note that we
- * do this only after failure, so when you create the
- * trigger file, we still finish replaying as much as we
- * can from archive and pg_wal before failover.
+ * Check to see if promotion is requested. Note that we do
+ * this only after failure, so when you promote, we still
+ * finish replaying as much as we can from archive and
+ * pg_wal before failover.
*/
if (StandbyMode && CheckForStandbyTrigger())
{
XLogPrefetcherComputeStats(xlogprefetcher);
/*
- * Wait for more WAL to arrive. Time out after 5 seconds
- * to react to a trigger file promptly and to check if the
- * WAL receiver is still active.
+ * Wait for more WAL to arrive, when we will be woken
+ * immediately by the WAL receiver.
*/
(void) WaitLatch(&XLogRecoveryCtl->recoveryWakeupLatch,
- WL_LATCH_SET | WL_TIMEOUT |
- WL_EXIT_ON_PM_DEATH,
- 5000L, WAIT_EVENT_RECOVERY_WAL_STREAM);
+ WL_LATCH_SET | WL_EXIT_ON_PM_DEATH,
+ -1L,
+ WAIT_EVENT_RECOVERY_WAL_STREAM);
ResetLatch(&XLogRecoveryCtl->recoveryWakeupLatch);
break;
}
}
/*
- * Check to see whether the user-specified trigger file exists and whether a
- * promote request has arrived. If either condition holds, return true.
+ * Check whether a promote request has arrived.
*/
static bool
CheckForStandbyTrigger(void)
{
- struct stat stat_buf;
-
if (LocalPromoteIsTriggered)
return true;
return true;
}
- if (PromoteTriggerFile == NULL || strcmp(PromoteTriggerFile, "") == 0)
- return false;
-
- if (stat(PromoteTriggerFile, &stat_buf) == 0)
- {
- ereport(LOG,
- (errmsg("promote trigger file found: %s", PromoteTriggerFile)));
- unlink(PromoteTriggerFile);
- SetPromoteIsTriggered();
- return true;
- }
- else if (errno != ENOENT)
- ereport(ERROR,
- (errcode_for_file_access(),
- errmsg("could not stat promote trigger file \"%s\": %m",
- PromoteTriggerFile)));
-
return false;
}