mirror of
https://github.com/postgres/postgres.git
synced 2025-07-31 22:04:40 +03:00
Add pg_promote function
This function is able to promote a standby with this new SQL-callable function. Execution access can be granted to non-superusers so that failover tools can observe the principle of least privilege. Catalog version is bumped. Author: Laurenz Albe Reviewed-by: Michael Paquier, Masahiko Sawada Discussion: https://postgr.es/m/6e7c79b3ec916cf49742fb8849ed17cd87aed620.camel@cybertec.at
This commit is contained in:
@ -19202,6 +19202,9 @@ postgres=# SELECT * FROM pg_walfile_name_offset(pg_stop_backup());
|
||||
<indexterm>
|
||||
<primary>pg_is_wal_replay_paused</primary>
|
||||
</indexterm>
|
||||
<indexterm>
|
||||
<primary>pg_promote</primary>
|
||||
</indexterm>
|
||||
<indexterm>
|
||||
<primary>pg_wal_replay_pause</primary>
|
||||
</indexterm>
|
||||
@ -19232,6 +19235,22 @@ postgres=# SELECT * FROM pg_walfile_name_offset(pg_stop_backup());
|
||||
<entry>True if recovery is paused.
|
||||
</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>
|
||||
<literal><function>pg_promote(<parameter>wait</parameter> <type>boolean</type> DEFAULT true, <parameter>wait_seconds</parameter> <type>integer</type> DEFAULT 60)</function></literal>
|
||||
</entry>
|
||||
<entry><type>boolean</type></entry>
|
||||
<entry>
|
||||
Promotes a physical standby server. Returns <literal>true</literal>
|
||||
if promotion is successful and <literal>false</literal> otherwise.
|
||||
With <parameter>wait</parameter> set to <literal>true</literal>, the
|
||||
default, the function waits until promotion is completed or
|
||||
<parameter>wait_seconds</parameter> seconds have passed, otherwise the
|
||||
function returns immediately after sending the promotion signal to the
|
||||
postmaster. This function is restricted to superusers by default, but
|
||||
other users can be granted EXECUTE to run the function.
|
||||
</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>
|
||||
<literal><function>pg_wal_replay_pause()</function></literal>
|
||||
|
@ -1471,14 +1471,17 @@ synchronous_standby_names = 'ANY 2 (s1, s2, s3)'
|
||||
</para>
|
||||
|
||||
<para>
|
||||
To trigger failover of a log-shipping standby server,
|
||||
run <command>pg_ctl promote</command> or create a trigger
|
||||
file with the file name and path specified by the <varname>trigger_file</varname>
|
||||
setting in <filename>recovery.conf</filename>. If you're planning to use
|
||||
<command>pg_ctl promote</command> to fail over, <varname>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.
|
||||
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>trigger_file</varname> setting in
|
||||
<filename>recovery.conf</filename>. If you're planning to use
|
||||
<command>pg_ctl promote</command> or to call
|
||||
<function>pg_promote</function> to fail over,
|
||||
<varname>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>
|
||||
</sect1>
|
||||
|
||||
|
@ -1268,7 +1268,7 @@ postgres 27093 0.0 0.0 30096 2752 ? Ss 11:34 0:00 postgres: ser
|
||||
<entry>Waiting in an extension.</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry morerows="33"><literal>IPC</literal></entry>
|
||||
<entry morerows="34"><literal>IPC</literal></entry>
|
||||
<entry><literal>BgWorkerShutdown</literal></entry>
|
||||
<entry>Waiting for background worker to shut down.</entry>
|
||||
</row>
|
||||
@ -1388,6 +1388,10 @@ postgres 27093 0.0 0.0 30096 2752 ? Ss 11:34 0:00 postgres: ser
|
||||
<entry><literal>ProcArrayGroupUpdate</literal></entry>
|
||||
<entry>Waiting for group leader to clear transaction id at transaction end.</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><literal>Promote</literal></entry>
|
||||
<entry>Waiting for standby promotion.</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><literal>ReplicationOriginDrop</literal></entry>
|
||||
<entry>Waiting for a replication origin to become inactive to be dropped.</entry>
|
||||
|
@ -439,7 +439,8 @@ restore_command = 'copy "C:\\server\\archivedir\\%f" "%p"' # Windows
|
||||
<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>.
|
||||
the standby using <command>pg_ctl promote</command> or calling
|
||||
<function>pg_promote</function>.
|
||||
This setting has no effect if <varname>standby_mode</varname> is <literal>off</literal>.
|
||||
</para>
|
||||
</listitem>
|
||||
|
Reference in New Issue
Block a user