summaryrefslogtreecommitdiff
path: root/doc/src
diff options
context:
space:
mode:
authorMichael Paquier <michael@paquier.xyz>2018-10-25 09:46:00 +0900
committerMichael Paquier <michael@paquier.xyz>2018-10-25 09:46:00 +0900
commit10074651e3355e2405015f6253602be8344bc829 (patch)
tree3b53798231baca437d9c27f934e010c9d4bcf74a /doc/src
parent0a8590b2a09e7a9e10612bc38d5e872b0c234eca (diff)
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
Diffstat (limited to 'doc/src')
-rw-r--r--doc/src/sgml/func.sgml19
-rw-r--r--doc/src/sgml/high-availability.sgml19
-rw-r--r--doc/src/sgml/monitoring.sgml6
-rw-r--r--doc/src/sgml/recovery-config.sgml3
4 files changed, 37 insertions, 10 deletions
diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml
index 5193df33666..96d45419e57 100644
--- a/doc/src/sgml/func.sgml
+++ b/doc/src/sgml/func.sgml
@@ -19203,6 +19203,9 @@ postgres=# SELECT * FROM pg_walfile_name_offset(pg_stop_backup());
<primary>pg_is_wal_replay_paused</primary>
</indexterm>
<indexterm>
+ <primary>pg_promote</primary>
+ </indexterm>
+ <indexterm>
<primary>pg_wal_replay_pause</primary>
</indexterm>
<indexterm>
@@ -19234,6 +19237,22 @@ postgres=# SELECT * FROM pg_walfile_name_offset(pg_stop_backup());
</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>
</entry>
<entry><type>void</type></entry>
diff --git a/doc/src/sgml/high-availability.sgml b/doc/src/sgml/high-availability.sgml
index ebcb3daaed6..faf8e718549 100644
--- a/doc/src/sgml/high-availability.sgml
+++ b/doc/src/sgml/high-availability.sgml
@@ -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>
diff --git a/doc/src/sgml/monitoring.sgml b/doc/src/sgml/monitoring.sgml
index d4285ea56ad..add71458e26 100644
--- a/doc/src/sgml/monitoring.sgml
+++ b/doc/src/sgml/monitoring.sgml
@@ -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>
@@ -1389,6 +1389,10 @@ postgres 27093 0.0 0.0 30096 2752 ? Ss 11:34 0:00 postgres: ser
<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>
</row>
diff --git a/doc/src/sgml/recovery-config.sgml b/doc/src/sgml/recovery-config.sgml
index 92825fdf192..a2bdffda94d 100644
--- a/doc/src/sgml/recovery-config.sgml
+++ b/doc/src/sgml/recovery-config.sgml
@@ -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>