mirror of
https://github.com/postgres/postgres.git
synced 2025-04-24 10:47:04 +03:00
Remove promote_trigger_file.
Previously, an idle startup (recovery) process would wake up every 5 seconds to have a chance to poll for promote_trigger_file, even if that GUC was not configured. That promotion triggering mechanism was effectively superseded by pg_ctl promote and pg_promote() a long time ago. There probably aren't many users left and it's very easy to change to the modern mechanisms, so we agreed to remove the feature. This is part of a campaign to reduce wakeups on idle systems. Author: Simon Riggs <simon.riggs@enterprisedb.com> Reviewed-by: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com> Reviewed-by: Robert Haas <robertmhaas@gmail.com> Reviewed-by: Thomas Munro <thomas.munro@gmail.com> Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> Reviewed-by: Ian Lawrence Barwick <barwick@gmail.com> Discussion: https://postgr.es/m/CANbhV-FsjnzVOQGBpQ589%3DnWuL1Ex0Ykn74Nh1hEjp2usZSR5g%40mail.gmail.com
This commit is contained in:
parent
f0cd57f852
commit
cd4329d939
@ -34,14 +34,11 @@
|
|||||||
</para>
|
</para>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
The
|
PostgreSQL 15 and below had a setting
|
||||||
<literal>trigger_file</literal>
|
<literal>promote_trigger_file</literal>, or
|
||||||
<indexterm>
|
<literal>trigger_file</literal> before 12.
|
||||||
<primary>trigger_file</primary>
|
Use <command>pg_ctl promote</command> or call
|
||||||
<see>promote_trigger_file</see>
|
<function>pg_promote()</function> to promote a standby instead.
|
||||||
</indexterm>
|
|
||||||
setting has been renamed to
|
|
||||||
<xref linkend="guc-promote-trigger-file"/>.
|
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
|
@ -4610,24 +4610,6 @@ ANY <replaceable class="parameter">num_sync</replaceable> ( <replaceable class="
|
|||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry id="guc-promote-trigger-file" xreflabel="promote_trigger_file">
|
|
||||||
<term><varname>promote_trigger_file</varname> (<type>string</type>)
|
|
||||||
<indexterm>
|
|
||||||
<primary><varname>promote_trigger_file</varname> configuration parameter</primary>
|
|
||||||
</indexterm>
|
|
||||||
</term>
|
|
||||||
<listitem>
|
|
||||||
<para>
|
|
||||||
Specifies a trigger file whose presence ends recovery in the
|
|
||||||
standby. Even if this value is not set, you can still promote
|
|
||||||
the standby using <command>pg_ctl promote</command> or calling
|
|
||||||
<function>pg_promote()</function>.
|
|
||||||
This parameter can only be set in the <filename>postgresql.conf</filename>
|
|
||||||
file or on the server command line.
|
|
||||||
</para>
|
|
||||||
</listitem>
|
|
||||||
</varlistentry>
|
|
||||||
|
|
||||||
<varlistentry id="guc-hot-standby" xreflabel="hot_standby">
|
<varlistentry id="guc-hot-standby" xreflabel="hot_standby">
|
||||||
<term><varname>hot_standby</varname> (<type>boolean</type>)
|
<term><varname>hot_standby</varname> (<type>boolean</type>)
|
||||||
<indexterm>
|
<indexterm>
|
||||||
|
@ -653,11 +653,10 @@ protocol to make nodes agree on a serializable transactional order.
|
|||||||
|
|
||||||
<para>
|
<para>
|
||||||
Standby mode is exited and the server switches to normal operation
|
Standby mode is exited and the server switches to normal operation
|
||||||
when <command>pg_ctl promote</command> is run,
|
when <command>pg_ctl promote</command> is run, or
|
||||||
<function>pg_promote()</function> is called, or a trigger file is found
|
<function>pg_promote()</function> is called. Before failover,
|
||||||
(<varname>promote_trigger_file</varname>). Before failover,
|
any WAL immediately available in the archive or in <filename>pg_wal</filename>
|
||||||
any WAL immediately available in the archive or in <filename>pg_wal</filename> will be
|
will be restored, but no attempt is made to connect to the primary.
|
||||||
restored, but no attempt is made to connect to the primary.
|
|
||||||
</para>
|
</para>
|
||||||
</sect2>
|
</sect2>
|
||||||
|
|
||||||
@ -1483,15 +1482,10 @@ synchronous_standby_names = 'ANY 2 (s1, s2, s3)'
|
|||||||
|
|
||||||
<para>
|
<para>
|
||||||
To trigger failover of a log-shipping standby server, run
|
To trigger failover of a log-shipping standby server, run
|
||||||
<command>pg_ctl promote</command>, call <function>pg_promote()</function>,
|
<command>pg_ctl promote</command> or call <function>pg_promote()</function>.
|
||||||
or create a trigger file with the file name and path specified by the
|
If you're setting up reporting servers that are only used to offload
|
||||||
<varname>promote_trigger_file</varname>. If you're planning to use
|
read-only queries from the primary, not for high availability purposes,
|
||||||
<command>pg_ctl promote</command> or to call
|
you don't need to promote.
|
||||||
<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.
|
|
||||||
</para>
|
</para>
|
||||||
</sect1>
|
</sect1>
|
||||||
|
|
||||||
|
@ -95,7 +95,6 @@ int recovery_min_apply_delay = 0;
|
|||||||
/* options formerly taken from recovery.conf for XLOG streaming */
|
/* options formerly taken from recovery.conf for XLOG streaming */
|
||||||
char *PrimaryConnInfo = NULL;
|
char *PrimaryConnInfo = NULL;
|
||||||
char *PrimarySlotName = NULL;
|
char *PrimarySlotName = NULL;
|
||||||
char *PromoteTriggerFile = NULL;
|
|
||||||
bool wal_receiver_create_temp_slot = false;
|
bool wal_receiver_create_temp_slot = false;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -318,8 +317,8 @@ typedef struct XLogRecoveryCtlData
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* recoveryWakeupLatch is used to wake up the startup process to continue
|
* 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
|
* WAL replay, if it is waiting for WAL to arrive or promotion to be
|
||||||
* to appear.
|
* requested.
|
||||||
*
|
*
|
||||||
* Note that the startup process also uses another latch, its procLatch,
|
* Note that the startup process also uses another latch, its procLatch,
|
||||||
* to wait for recovery conflict. If we get rid of recoveryWakeupLatch for
|
* to wait for recovery conflict. If we get rid of recoveryWakeupLatch for
|
||||||
@ -2906,10 +2905,7 @@ recoveryApplyDelay(XLogReaderState *record)
|
|||||||
{
|
{
|
||||||
ResetLatch(&XLogRecoveryCtl->recoveryWakeupLatch);
|
ResetLatch(&XLogRecoveryCtl->recoveryWakeupLatch);
|
||||||
|
|
||||||
/*
|
/* This might change recovery_min_apply_delay. */
|
||||||
* This might change recovery_min_apply_delay or the trigger file's
|
|
||||||
* location.
|
|
||||||
*/
|
|
||||||
HandleStartupProcInterrupts();
|
HandleStartupProcInterrupts();
|
||||||
|
|
||||||
if (CheckForStandbyTrigger())
|
if (CheckForStandbyTrigger())
|
||||||
@ -3155,8 +3151,8 @@ ReadRecord(XLogPrefetcher *xlogprefetcher, int emode,
|
|||||||
* as for waiting for the requested WAL record to arrive in standby mode.
|
* 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
|
* '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
|
* "end of WAL" situations in archive recovery, or in standby mode when
|
||||||
* trigger file is found. If set to WARNING or below, XLogPageRead() returns
|
* promotion is triggered. If set to WARNING or below, XLogPageRead() returns
|
||||||
* XLREAD_FAIL in those situations, on higher log levels the ereport() won't
|
* XLREAD_FAIL in those situations, on higher log levels the ereport() won't
|
||||||
* return.
|
* return.
|
||||||
*
|
*
|
||||||
@ -3424,7 +3420,7 @@ WaitForWALToBecomeAvailable(XLogRecPtr RecPtr, bool randAccess,
|
|||||||
*
|
*
|
||||||
* 1. Read from either archive or pg_wal (XLOG_FROM_ARCHIVE), or just
|
* 1. Read from either archive or pg_wal (XLOG_FROM_ARCHIVE), or just
|
||||||
* pg_wal (XLOG_FROM_PG_WAL)
|
* 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)
|
* 3. Read from primary server via walreceiver (XLOG_FROM_STREAM)
|
||||||
* 4. Rescan timelines
|
* 4. Rescan timelines
|
||||||
* 5. Sleep wal_retrieve_retry_interval milliseconds, and loop back to 1.
|
* 5. Sleep wal_retrieve_retry_interval milliseconds, and loop back to 1.
|
||||||
@ -3481,10 +3477,10 @@ WaitForWALToBecomeAvailable(XLogRecPtr RecPtr, bool randAccess,
|
|||||||
case XLOG_FROM_PG_WAL:
|
case XLOG_FROM_PG_WAL:
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check to see if the trigger file exists. Note that we
|
* Check to see if promotion is requested. Note that we do
|
||||||
* do this only after failure, so when you create the
|
* this only after failure, so when you promote, we still
|
||||||
* trigger file, we still finish replaying as much as we
|
* finish replaying as much as we can from archive and
|
||||||
* can from archive and pg_wal before failover.
|
* pg_wal before failover.
|
||||||
*/
|
*/
|
||||||
if (StandbyMode && CheckForStandbyTrigger())
|
if (StandbyMode && CheckForStandbyTrigger())
|
||||||
{
|
{
|
||||||
@ -3840,14 +3836,13 @@ WaitForWALToBecomeAvailable(XLogRecPtr RecPtr, bool randAccess,
|
|||||||
XLogPrefetcherComputeStats(xlogprefetcher);
|
XLogPrefetcherComputeStats(xlogprefetcher);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Wait for more WAL to arrive. Time out after 5 seconds
|
* Wait for more WAL to arrive, when we will be woken
|
||||||
* to react to a trigger file promptly and to check if the
|
* immediately by the WAL receiver.
|
||||||
* WAL receiver is still active.
|
|
||||||
*/
|
*/
|
||||||
(void) WaitLatch(&XLogRecoveryCtl->recoveryWakeupLatch,
|
(void) WaitLatch(&XLogRecoveryCtl->recoveryWakeupLatch,
|
||||||
WL_LATCH_SET | WL_TIMEOUT |
|
WL_LATCH_SET | WL_EXIT_ON_PM_DEATH,
|
||||||
WL_EXIT_ON_PM_DEATH,
|
-1L,
|
||||||
5000L, WAIT_EVENT_RECOVERY_WAL_STREAM);
|
WAIT_EVENT_RECOVERY_WAL_STREAM);
|
||||||
ResetLatch(&XLogRecoveryCtl->recoveryWakeupLatch);
|
ResetLatch(&XLogRecoveryCtl->recoveryWakeupLatch);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -4294,14 +4289,11 @@ SetPromoteIsTriggered(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check to see whether the user-specified trigger file exists and whether a
|
* Check whether a promote request has arrived.
|
||||||
* promote request has arrived. If either condition holds, return true.
|
|
||||||
*/
|
*/
|
||||||
static bool
|
static bool
|
||||||
CheckForStandbyTrigger(void)
|
CheckForStandbyTrigger(void)
|
||||||
{
|
{
|
||||||
struct stat stat_buf;
|
|
||||||
|
|
||||||
if (LocalPromoteIsTriggered)
|
if (LocalPromoteIsTriggered)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@ -4314,23 +4306,6 @@ CheckForStandbyTrigger(void)
|
|||||||
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3819,16 +3819,6 @@ struct config_string ConfigureNamesString[] =
|
|||||||
check_recovery_target_lsn, assign_recovery_target_lsn, NULL
|
check_recovery_target_lsn, assign_recovery_target_lsn, NULL
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
|
||||||
{"promote_trigger_file", PGC_SIGHUP, REPLICATION_STANDBY,
|
|
||||||
gettext_noop("Specifies a file name whose presence ends recovery in the standby."),
|
|
||||||
NULL
|
|
||||||
},
|
|
||||||
&PromoteTriggerFile,
|
|
||||||
"",
|
|
||||||
NULL, NULL, NULL
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
{
|
||||||
{"primary_conninfo", PGC_SIGHUP, REPLICATION_STANDBY,
|
{"primary_conninfo", PGC_SIGHUP, REPLICATION_STANDBY,
|
||||||
gettext_noop("Sets the connection string to be used to connect to the sending server."),
|
gettext_noop("Sets the connection string to be used to connect to the sending server."),
|
||||||
|
@ -331,7 +331,6 @@
|
|||||||
|
|
||||||
#primary_conninfo = '' # connection string to sending server
|
#primary_conninfo = '' # connection string to sending server
|
||||||
#primary_slot_name = '' # replication slot on sending server
|
#primary_slot_name = '' # replication slot on sending server
|
||||||
#promote_trigger_file = '' # file name whose presence ends recovery
|
|
||||||
#hot_standby = on # "off" disallows queries during recovery
|
#hot_standby = on # "off" disallows queries during recovery
|
||||||
# (change requires restart)
|
# (change requires restart)
|
||||||
#max_standby_archive_delay = 30s # max delay before canceling queries
|
#max_standby_archive_delay = 30s # max delay before canceling queries
|
||||||
|
@ -65,7 +65,6 @@ extern PGDLLIMPORT TimestampTz recoveryTargetTime;
|
|||||||
extern PGDLLIMPORT const char *recoveryTargetName;
|
extern PGDLLIMPORT const char *recoveryTargetName;
|
||||||
extern PGDLLIMPORT XLogRecPtr recoveryTargetLSN;
|
extern PGDLLIMPORT XLogRecPtr recoveryTargetLSN;
|
||||||
extern PGDLLIMPORT RecoveryTargetType recoveryTarget;
|
extern PGDLLIMPORT RecoveryTargetType recoveryTarget;
|
||||||
extern PGDLLIMPORT char *PromoteTriggerFile;
|
|
||||||
extern PGDLLIMPORT bool wal_receiver_create_temp_slot;
|
extern PGDLLIMPORT bool wal_receiver_create_temp_slot;
|
||||||
extern PGDLLIMPORT RecoveryTargetTimeLineGoal recoveryTargetTimeLineGoal;
|
extern PGDLLIMPORT RecoveryTargetTimeLineGoal recoveryTargetTimeLineGoal;
|
||||||
extern PGDLLIMPORT TimeLineID recoveryTargetTLIRequested;
|
extern PGDLLIMPORT TimeLineID recoveryTargetTLIRequested;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user