1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-31 22:04:40 +03:00

Introduce a new GUC_REPORT setting "in_hot_standby".

Aside from being queriable via SHOW, this value is sent to the client
immediately at session startup, and again later on if the server gets
promoted to primary during the session.  The immediate report will be
used in an upcoming patch to avoid an extra round trip when trying to
connect to a primary server.

Haribabu Kommi, Greg Nancarrow, Tom Lane; reviewed at various times
by Laurenz Albe, Takayuki Tsunakawa, Peter Smith.

Discussion: https://postgr.es/m/CAF3+xM+8-ztOkaV9gHiJ3wfgENTq97QcjXQt+rbFQ6F7oNzt9A@mail.gmail.com
This commit is contained in:
Tom Lane
2021-01-05 16:18:01 -05:00
parent 47b2ed1d06
commit bf8a662c9a
6 changed files with 91 additions and 11 deletions

View File

@ -9600,13 +9600,14 @@ dynamic_library_path = 'C:\tools\postgresql;H:\my_project\lib;$libdir'
<title>Preset Options</title>
<para>
The following <quote>parameters</quote> are read-only, and are determined
when <productname>PostgreSQL</productname> is compiled or when it is
installed. As such, they have been excluded from the sample
The following <quote>parameters</quote> are read-only.
As such, they have been excluded from the sample
<filename>postgresql.conf</filename> file. These options report
various aspects of <productname>PostgreSQL</productname> behavior
that might be of interest to certain applications, particularly
administrative front-ends.
Most of them are determined when <productname>PostgreSQL</productname>
is compiled or when it is installed.
</para>
<variablelist>
@ -9651,10 +9652,11 @@ dynamic_library_path = 'C:\tools\postgresql;H:\my_project\lib;$libdir'
</term>
<listitem>
<para>
On Unix systems this parameter reports the permissions of the data
directory defined by (<xref linkend="guc-data-directory"/>) at startup.
On Unix systems this parameter reports the permissions the data
directory (defined by <xref linkend="guc-data-directory"/>)
had at server startup.
(On Microsoft Windows this parameter will always display
<literal>0700</literal>). See
<literal>0700</literal>.) See
<xref linkend="app-initdb-allow-group-access"/> for more information.
</para>
</listitem>
@ -9695,6 +9697,23 @@ dynamic_library_path = 'C:\tools\postgresql;H:\my_project\lib;$libdir'
</listitem>
</varlistentry>
<varlistentry id="guc-in-hot-standby" xreflabel="in_hot_standby">
<term><varname>in_hot_standby</varname> (<type>boolean</type>)
<indexterm>
<primary><varname>in_hot_standby</varname> configuration parameter</primary>
</indexterm>
</term>
<listitem>
<para>
Reports whether the server is currently in hot standby mode. When
this is <literal>on</literal>, all transactions are forced to be
read-only. Within a session, this can change only if the server is
promoted to be primary. See <xref linkend="hot-standby"/> for more
information.
</para>
</listitem>
</varlistentry>
<varlistentry id="guc-lc-collate" xreflabel="lc_collate">
<term><varname>lc_collate</varname> (<type>string</type>)
<indexterm>

View File

@ -1859,8 +1859,11 @@ if (!triggered)
</para>
<para>
Users will be able to tell whether their session is read-only by
issuing <command>SHOW transaction_read_only</command>. In addition, a set of
Users can determine whether hot standby is currently active for their
session by issuing <command>SHOW in_hot_standby</command>.
(In server versions before 14, the <varname>in_hot_standby</varname>
parameter did not exist; a workable substitute method for older servers
is <command>SHOW transaction_read_only</command>.) In addition, a set of
functions (<xref linkend="functions-recovery-info-table"/>) allow users to
access information about the standby server. These allow you to write
programs that are aware of the current state of the database. These

View File

@ -2150,6 +2150,7 @@ const char *PQparameterStatus(const PGconn *conn, const char *paramName);
<varname>server_encoding</varname>,
<varname>client_encoding</varname>,
<varname>application_name</varname>,
<varname>in_hot_standby</varname>,
<varname>is_superuser</varname>,
<varname>session_authorization</varname>,
<varname>DateStyle</varname>,
@ -2162,7 +2163,10 @@ const char *PQparameterStatus(const PGconn *conn, const char *paramName);
<varname>standard_conforming_strings</varname> was not reported by releases
before 8.1;
<varname>IntervalStyle</varname> was not reported by releases before 8.4;
<varname>application_name</varname> was not reported by releases before 9.0.)
<varname>application_name</varname> was not reported by releases before
9.0;
<varname>in_hot_standby</varname> was not reported by releases before
14.)
Note that
<varname>server_version</varname>,
<varname>server_encoding</varname> and

View File

@ -1278,6 +1278,7 @@ SELCT 1/0;<!-- this typo is intentional -->
<varname>server_encoding</varname>,
<varname>client_encoding</varname>,
<varname>application_name</varname>,
<varname>in_hot_standby</varname>,
<varname>is_superuser</varname>,
<varname>session_authorization</varname>,
<varname>DateStyle</varname>,
@ -1290,7 +1291,10 @@ SELCT 1/0;<!-- this typo is intentional -->
<varname>standard_conforming_strings</varname> was not reported by releases
before 8.1;
<varname>IntervalStyle</varname> was not reported by releases before 8.4;
<varname>application_name</varname> was not reported by releases before 9.0.)
<varname>application_name</varname> was not reported by releases before
9.0;
<varname>in_hot_standby</varname> was not reported by releases before
14.)
Note that
<varname>server_version</varname>,
<varname>server_encoding</varname> and