Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit cd4329d

Browse filesBrowse files
committed
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
1 parent f0cd57f commit cd4329d
Copy full SHA for cd4329d

File tree

7 files changed

+29
-93
lines changed
Filter options

7 files changed

+29
-93
lines changed

‎doc/src/sgml/appendix-obsolete-recovery-config.sgml

Copy file name to clipboardExpand all lines: doc/src/sgml/appendix-obsolete-recovery-config.sgml
+5-8Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,11 @@
3434
</para>
3535

3636
<para>
37-
The
38-
<literal>trigger_file</literal>
39-
<indexterm>
40-
<primary>trigger_file</primary>
41-
<see>promote_trigger_file</see>
42-
</indexterm>
43-
setting has been renamed to
44-
<xref linkend="guc-promote-trigger-file"/>.
37+
PostgreSQL 15 and below had a setting
38+
<literal>promote_trigger_file</literal>, or
39+
<literal>trigger_file</literal> before 12.
40+
Use <command>pg_ctl promote</command> or call
41+
<function>pg_promote()</function> to promote a standby instead.
4542
</para>
4643

4744
<para>

‎doc/src/sgml/config.sgml

Copy file name to clipboardExpand all lines: doc/src/sgml/config.sgml
-18Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4610,24 +4610,6 @@ ANY <replaceable class="parameter">num_sync</replaceable> ( <replaceable class="
46104610
</listitem>
46114611
</varlistentry>
46124612

4613-
<varlistentry id="guc-promote-trigger-file" xreflabel="promote_trigger_file">
4614-
<term><varname>promote_trigger_file</varname> (<type>string</type>)
4615-
<indexterm>
4616-
<primary><varname>promote_trigger_file</varname> configuration parameter</primary>
4617-
</indexterm>
4618-
</term>
4619-
<listitem>
4620-
<para>
4621-
Specifies a trigger file whose presence ends recovery in the
4622-
standby. Even if this value is not set, you can still promote
4623-
the standby using <command>pg_ctl promote</command> or calling
4624-
<function>pg_promote()</function>.
4625-
This parameter can only be set in the <filename>postgresql.conf</filename>
4626-
file or on the server command line.
4627-
</para>
4628-
</listitem>
4629-
</varlistentry>
4630-
46314613
<varlistentry id="guc-hot-standby" xreflabel="hot_standby">
46324614
<term><varname>hot_standby</varname> (<type>boolean</type>)
46334615
<indexterm>

‎doc/src/sgml/high-availability.sgml

Copy file name to clipboardExpand all lines: doc/src/sgml/high-availability.sgml
+8-14Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -653,11 +653,10 @@ protocol to make nodes agree on a serializable transactional order.
653653

654654
<para>
655655
Standby mode is exited and the server switches to normal operation
656-
when <command>pg_ctl promote</command> is run,
657-
<function>pg_promote()</function> is called, or a trigger file is found
658-
(<varname>promote_trigger_file</varname>). Before failover,
659-
any WAL immediately available in the archive or in <filename>pg_wal</filename> will be
660-
restored, but no attempt is made to connect to the primary.
656+
when <command>pg_ctl promote</command> is run, or
657+
<function>pg_promote()</function> is called. Before failover,
658+
any WAL immediately available in the archive or in <filename>pg_wal</filename>
659+
will be restored, but no attempt is made to connect to the primary.
661660
</para>
662661
</sect2>
663662

@@ -1483,15 +1482,10 @@ synchronous_standby_names = 'ANY 2 (s1, s2, s3)'
14831482

14841483
<para>
14851484
To trigger failover of a log-shipping standby server, run
1486-
<command>pg_ctl promote</command>, call <function>pg_promote()</function>,
1487-
or create a trigger file with the file name and path specified by the
1488-
<varname>promote_trigger_file</varname>. If you're planning to use
1489-
<command>pg_ctl promote</command> or to call
1490-
<function>pg_promote()</function> to fail over,
1491-
<varname>promote_trigger_file</varname> is not required. If you're
1492-
setting up the reporting servers that are only used to offload read-only
1493-
queries from the primary, not for high availability purposes, you don't
1494-
need to promote it.
1485+
<command>pg_ctl promote</command> or call <function>pg_promote()</function>.
1486+
If you're setting up reporting servers that are only used to offload
1487+
read-only queries from the primary, not for high availability purposes,
1488+
you don't need to promote.
14951489
</para>
14961490
</sect1>
14971491

‎src/backend/access/transam/xlogrecovery.c

Copy file name to clipboardExpand all lines: src/backend/access/transam/xlogrecovery.c
+16-41Lines changed: 16 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ int recovery_min_apply_delay = 0;
9595
/* options formerly taken from recovery.conf for XLOG streaming */
9696
char *PrimaryConnInfo = NULL;
9797
char *PrimarySlotName = NULL;
98-
char *PromoteTriggerFile = NULL;
9998
bool 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
*/
43004294
static bool
43014295
CheckForStandbyTrigger(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

‎src/backend/utils/misc/guc_tables.c

Copy file name to clipboardExpand all lines: src/backend/utils/misc/guc_tables.c
-10Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3819,16 +3819,6 @@ struct config_string ConfigureNamesString[] =
38193819
check_recovery_target_lsn, assign_recovery_target_lsn, NULL
38203820
},
38213821

3822-
{
3823-
{"promote_trigger_file", PGC_SIGHUP, REPLICATION_STANDBY,
3824-
gettext_noop("Specifies a file name whose presence ends recovery in the standby."),
3825-
NULL
3826-
},
3827-
&PromoteTriggerFile,
3828-
"",
3829-
NULL, NULL, NULL
3830-
},
3831-
38323822
{
38333823
{"primary_conninfo", PGC_SIGHUP, REPLICATION_STANDBY,
38343824
gettext_noop("Sets the connection string to be used to connect to the sending server."),

‎src/backend/utils/misc/postgresql.conf.sample

Copy file name to clipboardExpand all lines: src/backend/utils/misc/postgresql.conf.sample
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,6 @@
331331

332332
#primary_conninfo = '' # connection string to sending server
333333
#primary_slot_name = '' # replication slot on sending server
334-
#promote_trigger_file = '' # file name whose presence ends recovery
335334
#hot_standby = on # "off" disallows queries during recovery
336335
# (change requires restart)
337336
#max_standby_archive_delay = 30s # max delay before canceling queries

‎src/include/access/xlogrecovery.h

Copy file name to clipboardExpand all lines: src/include/access/xlogrecovery.h
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ extern PGDLLIMPORT TimestampTz recoveryTargetTime;
6565
extern PGDLLIMPORT const char *recoveryTargetName;
6666
extern PGDLLIMPORT XLogRecPtr recoveryTargetLSN;
6767
extern PGDLLIMPORT RecoveryTargetType recoveryTarget;
68-
extern PGDLLIMPORT char *PromoteTriggerFile;
6968
extern PGDLLIMPORT bool wal_receiver_create_temp_slot;
7069
extern PGDLLIMPORT RecoveryTargetTimeLineGoal recoveryTargetTimeLineGoal;
7170
extern PGDLLIMPORT TimeLineID recoveryTargetTLIRequested;

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.