Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 60a81ad

Browse files
committed
Reclassify replication-related GUC variables as "master" and "standby".
Per discussion, this structure seems more understandable than what was there before. Make config.sgml and postgresql.conf.sample agree. In passing do a bit of editorial work on the variable descriptions.
1 parent 5b2b444 commit 60a81ad

File tree

4 files changed

+103
-72
lines changed

4 files changed

+103
-72
lines changed

doc/src/sgml/config.sgml

+67-48
Original file line numberDiff line numberDiff line change
@@ -1844,9 +1844,9 @@ SET ENABLE_SEQSCAN TO OFF;
18441844
<varname>archive_mode</> and <varname>archive_command</> are
18451845
separate variables so that <varname>archive_command</> can be
18461846
changed without leaving archiving mode.
1847-
This parameter can only be set at server start. <varname>wal_level</>
1848-
must be set to <literal>archive</> or <literal>hot_standby</> to
1849-
enable <varname>archive_mode</>.
1847+
This parameter can only be set at server start.
1848+
<varname>archive_mode</> cannot be enabled when
1849+
<varname>wal_level</> is set to <literal>minimal</>.
18501850
</para>
18511851
</listitem>
18521852
</varlistentry>
@@ -1911,7 +1911,10 @@ SET ENABLE_SEQSCAN TO OFF;
19111911
files. Therefore, it is unwise to use a very short
19121912
<varname>archive_timeout</> &mdash; it will bloat your archive
19131913
storage. <varname>archive_timeout</> settings of a minute or so are
1914-
usually reasonable. This parameter can only be set in the
1914+
usually reasonable. You should consider using streaming replication,
1915+
instead of archiving, if you want data to be copied off the master
1916+
server more quickly than that.
1917+
This parameter can only be set in the
19151918
<filename>postgresql.conf</> file or on the server command line.
19161919
</para>
19171920
</listitem>
@@ -1920,14 +1923,32 @@ SET ENABLE_SEQSCAN TO OFF;
19201923
</variablelist>
19211924
</sect2>
19221925

1923-
<sect2 id="runtime-config-replication">
1924-
<title>Streaming Replication</title>
1926+
</sect1>
1927+
1928+
<sect1 id="runtime-config-replication">
1929+
<title>Replication</title>
1930+
1931+
<para>
1932+
These settings control the behavior of the built-in
1933+
<firstterm>streaming replication</> feature (see
1934+
<xref linkend="streaming-replication">).
1935+
Some parameters must be set on the master server, while others must be
1936+
set on the standby server(s) that will receive replication data.
1937+
</para>
1938+
1939+
<sect2 id="runtime-config-replication-master">
1940+
<title>Master Server</title>
19251941

19261942
<para>
1927-
These settings control the behavior of the built-in
1928-
<firstterm>streaming replication</> feature.
1929-
These parameters would be set on the primary server that is
1943+
These parameters can be set on the primary server that is
19301944
to send replication data to one or more standby servers.
1945+
Note that in addition to these parameters,
1946+
<xref linkend="guc-wal-level"> must be set appropriately on the master
1947+
server, and you will typically want to enable WAL archiving as
1948+
well (see <xref linkend="runtime-config-wal-archiving">).
1949+
The values of these parameters on standby servers are irrelevant,
1950+
although you may wish to set them there in preparation for the
1951+
possibility of a standby becoming the master.
19311952
</para>
19321953

19331954
<variablelist>
@@ -1995,7 +2016,7 @@ SET ENABLE_SEQSCAN TO OFF;
19952016
<filename>pg_xlog</>; the system might need to retain more segments
19962017
for WAL archival or to recover from a checkpoint. If
19972018
<varname>wal_keep_segments</> is zero (the default), the system
1998-
doesn't keep any extra segments for standby purposes, and the number
2019+
doesn't keep any extra segments for standby purposes, so the number
19992020
of old WAL segments available to standby servers is a function of
20002021
the location of the previous checkpoint and status of WAL
20012022
archiving. This parameter has no effect on restartpoints.
@@ -2057,50 +2078,45 @@ SET ENABLE_SEQSCAN TO OFF;
20572078
</para>
20582079
</listitem>
20592080
</varlistentry>
2060-
</variablelist>
2061-
</sect2>
2062-
2063-
<sect2 id="runtime-config-sync-rep">
2064-
<title>Synchronous Replication</title>
2065-
2066-
<para>
2067-
These settings control the behavior of the built-in
2068-
<firstterm>synchronous replication</> feature.
2069-
These parameters would be set on the primary server that is
2070-
to send replication data to one or more standby servers.
2071-
</para>
20722081

2073-
<variablelist>
20742082
<varlistentry id="guc-synchronous-standby-names" xreflabel="synchronous_standby_names">
20752083
<term><varname>synchronous_standby_names</varname> (<type>string</type>)</term>
20762084
<indexterm>
20772085
<primary><varname>synchronous_standby_names</> configuration parameter</primary>
20782086
</indexterm>
20792087
<listitem>
20802088
<para>
2081-
Specifies a priority ordered list of standby names that can offer
2082-
synchronous replication. At any one time there will be at most one
2083-
synchronous standby that will wake sleeping users following commit.
2084-
The synchronous standby will be the first named standby that is
2085-
both currently connected and streaming in real-time to the standby
2086-
(as shown by a state of <literal>STREAMING</literal>). Other standby servers
2087-
with listed later will become potential synchronous standbys.
2088-
If the current synchronous standby disconnects for whatever reason
2089-
it will be replaced immediately with the next highest priority standby.
2089+
Specifies a comma-separated list of standby names that can support
2090+
<firstterm>synchronous replication</>, as described in
2091+
<xref linkend="synchronous-replication">.
2092+
At any one time there will be at most one active synchronous standby;
2093+
transactions waiting for commit will be allowed to proceed after
2094+
this standby server confirms receipt of their data.
2095+
The synchronous standby will be the first standby named in this list
2096+
that is both currently connected and streaming data in real-time
2097+
(as shown by a state of <literal>STREAMING</literal> in the
2098+
<link linkend="monitoring-stats-views-table">
2099+
<literal>pg_stat_replication</></link> view).
2100+
Other standby servers appearing later in this list represent potential
2101+
synchronous standbys.
2102+
If the current synchronous standby disconnects for whatever reason,
2103+
it will be replaced immediately with the next-highest-priority standby.
20902104
Specifying more than one standby name can allow very high availability.
20912105
</para>
20922106
<para>
2093-
The standby name is currently taken as the <varname>application_name</> setting of the
2094-
standby, as set in the <varname>primary_conninfo</> on the standby. Names are
2095-
not enforced for uniqueness. In case of duplicates one of the standbys
2096-
will be chosen to be the synchronous standby, though exactly which
2097-
one is indeterminate.
2098-
The special entry <literal>*</> matches any application_name, including
2099-
the default application name of <literal>walreceiver</>.
2107+
The name of a standby server for this purpose is the
2108+
<varname>application_name</> setting of the standby, as set in the
2109+
<varname>primary_conninfo</> of the standby's walreceiver. There is
2110+
no mechanism to enforce uniqueness. In case of duplicates one of the
2111+
matching standbys will be chosen to be the synchronous standby, though
2112+
exactly which one is indeterminate.
2113+
The special entry <literal>*</> matches any
2114+
<varname>application_name</>, including the default application name
2115+
of <literal>walreceiver</>.
21002116
</para>
21012117
<para>
2102-
If no synchronous standby names are specified, then synchronous
2103-
replication is not enabled and transaction commit will never wait for
2118+
If no synchronous standby names are specified here, then synchronous
2119+
replication is not enabled and transaction commits will not wait for
21042120
replication. This is the default configuration. Even when
21052121
synchronous replication is enabled, individual transactions can be
21062122
configured not to wait for replication by setting the
@@ -2117,12 +2133,13 @@ SET ENABLE_SEQSCAN TO OFF;
21172133
</variablelist>
21182134
</sect2>
21192135

2120-
<sect2 id="runtime-config-standby">
2121-
<title>Standby Servers</title>
2136+
<sect2 id="runtime-config-replication-standby">
2137+
<title>Standby Servers</title>
21222138

21232139
<para>
21242140
These settings control the behavior of a standby server that is
2125-
to receive replication data.
2141+
to receive replication data. Their values on the master server
2142+
are irrelevant.
21262143
</para>
21272144

21282145
<variablelist>
@@ -2213,12 +2230,14 @@ SET ENABLE_SEQSCAN TO OFF;
22132230
<para>
22142231
Specifies the minimum frequency for the WAL receiver
22152232
process on the standby to send information about replication progress
2216-
to the primary, where they can be seen using the
2217-
<literal>pg_stat_replication</literal> view. The standby will report
2233+
to the primary, where it can be seen using the
2234+
<link linkend="monitoring-stats-views-table">
2235+
<literal>pg_stat_replication</></link> view. The standby will report
22182236
the last transaction log position it has written, the last position it
2219-
has flushed to disk, and the last position it has applied. The parameter
2237+
has flushed to disk, and the last position it has applied.
2238+
This parameter's
22202239
value is the maximum interval, in seconds, between reports. Updates are
2221-
sent each time the write or flush positions changed, or at least as
2240+
sent each time the write or flush positions change, or at least as
22222241
often as specified by this parameter. Thus, the apply position may
22232242
lag slightly behind the true position. Setting this parameter to zero
22242243
disables status updates completely. This parameter can only be set in

src/backend/utils/misc/guc.c

+17-15
Original file line numberDiff line numberDiff line change
@@ -551,10 +551,12 @@ const char *const config_group_names[] =
551551
gettext_noop("Write-Ahead Log / Checkpoints"),
552552
/* WAL_ARCHIVING */
553553
gettext_noop("Write-Ahead Log / Archiving"),
554-
/* WAL_REPLICATION */
555-
gettext_noop("Write-Ahead Log / Streaming Replication"),
556-
/* WAL_STANDBY_SERVERS */
557-
gettext_noop("Write-Ahead Log / Standby Servers"),
554+
/* REPLICATION */
555+
gettext_noop("Replication"),
556+
/* REPLICATION_MASTER */
557+
gettext_noop("Replication / Master Server"),
558+
/* REPLICATION_STANDBY */
559+
gettext_noop("Replication / Standby Servers"),
558560
/* QUERY_TUNING */
559561
gettext_noop("Query Tuning"),
560562
/* QUERY_TUNING_METHOD */
@@ -1357,7 +1359,7 @@ static struct config_bool ConfigureNamesBool[] =
13571359
},
13581360

13591361
{
1360-
{"hot_standby", PGC_POSTMASTER, WAL_STANDBY_SERVERS,
1362+
{"hot_standby", PGC_POSTMASTER, REPLICATION_STANDBY,
13611363
gettext_noop("Allows connections and queries during recovery."),
13621364
NULL
13631365
},
@@ -1367,7 +1369,7 @@ static struct config_bool ConfigureNamesBool[] =
13671369
},
13681370

13691371
{
1370-
{"hot_standby_feedback", PGC_SIGHUP, WAL_STANDBY_SERVERS,
1372+
{"hot_standby_feedback", PGC_SIGHUP, REPLICATION_STANDBY,
13711373
gettext_noop("Allows feedback from a hot standby to the primary that will avoid query conflicts."),
13721374
NULL
13731375
},
@@ -1534,7 +1536,7 @@ static struct config_int ConfigureNamesInt[] =
15341536
},
15351537

15361538
{
1537-
{"max_standby_archive_delay", PGC_SIGHUP, WAL_STANDBY_SERVERS,
1539+
{"max_standby_archive_delay", PGC_SIGHUP, REPLICATION_STANDBY,
15381540
gettext_noop("Sets the maximum delay before canceling queries when a hot standby server is processing archived WAL data."),
15391541
NULL,
15401542
GUC_UNIT_MS
@@ -1545,7 +1547,7 @@ static struct config_int ConfigureNamesInt[] =
15451547
},
15461548

15471549
{
1548-
{"max_standby_streaming_delay", PGC_SIGHUP, WAL_STANDBY_SERVERS,
1550+
{"max_standby_streaming_delay", PGC_SIGHUP, REPLICATION_STANDBY,
15491551
gettext_noop("Sets the maximum delay before canceling queries when a hot standby server is processing streamed WAL data."),
15501552
NULL,
15511553
GUC_UNIT_MS
@@ -1556,7 +1558,7 @@ static struct config_int ConfigureNamesInt[] =
15561558
},
15571559

15581560
{
1559-
{"wal_receiver_status_interval", PGC_SIGHUP, WAL_STANDBY_SERVERS,
1561+
{"wal_receiver_status_interval", PGC_SIGHUP, REPLICATION_STANDBY,
15601562
gettext_noop("Sets the maximum interval between WAL receiver status reports to the primary."),
15611563
NULL,
15621564
GUC_UNIT_S
@@ -1841,7 +1843,7 @@ static struct config_int ConfigureNamesInt[] =
18411843
},
18421844

18431845
{
1844-
{"vacuum_defer_cleanup_age", PGC_SIGHUP, WAL_REPLICATION,
1846+
{"vacuum_defer_cleanup_age", PGC_SIGHUP, REPLICATION_MASTER,
18451847
gettext_noop("Number of transactions by which VACUUM and HOT cleanup should be deferred, if any."),
18461848
NULL
18471849
},
@@ -1901,7 +1903,7 @@ static struct config_int ConfigureNamesInt[] =
19011903
},
19021904

19031905
{
1904-
{"wal_keep_segments", PGC_SIGHUP, WAL_REPLICATION,
1906+
{"wal_keep_segments", PGC_SIGHUP, REPLICATION_MASTER,
19051907
gettext_noop("Sets the number of WAL files held for standby servers."),
19061908
NULL
19071909
},
@@ -1969,7 +1971,7 @@ static struct config_int ConfigureNamesInt[] =
19691971

19701972
{
19711973
/* see max_connections */
1972-
{"max_wal_senders", PGC_POSTMASTER, WAL_REPLICATION,
1974+
{"max_wal_senders", PGC_POSTMASTER, REPLICATION_MASTER,
19731975
gettext_noop("Sets the maximum number of simultaneously running WAL sender processes."),
19741976
NULL
19751977
},
@@ -1979,7 +1981,7 @@ static struct config_int ConfigureNamesInt[] =
19791981
},
19801982

19811983
{
1982-
{"wal_sender_delay", PGC_SIGHUP, WAL_REPLICATION,
1984+
{"wal_sender_delay", PGC_SIGHUP, REPLICATION_MASTER,
19831985
gettext_noop("WAL sender sleep time between WAL replications."),
19841986
NULL,
19851987
GUC_UNIT_MS
@@ -1990,7 +1992,7 @@ static struct config_int ConfigureNamesInt[] =
19901992
},
19911993

19921994
{
1993-
{"replication_timeout", PGC_SIGHUP, WAL_REPLICATION,
1995+
{"replication_timeout", PGC_SIGHUP, REPLICATION_MASTER,
19941996
gettext_noop("Sets the maximum time to wait for WAL replication."),
19951997
NULL,
19961998
GUC_UNIT_MS
@@ -2954,7 +2956,7 @@ static struct config_string ConfigureNamesString[] =
29542956
},
29552957

29562958
{
2957-
{"synchronous_standby_names", PGC_SIGHUP, WAL_REPLICATION,
2959+
{"synchronous_standby_names", PGC_SIGHUP, REPLICATION_MASTER,
29582960
gettext_noop("List of names of potential synchronous standbys."),
29592961
NULL,
29602962
GUC_LIST_INPUT

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

+16-7
Original file line numberDiff line numberDiff line change
@@ -184,32 +184,41 @@
184184
#archive_timeout = 0 # force a logfile segment switch after this
185185
# number of seconds; 0 disables
186186

187-
# - Streaming Replication - Server Settings
188187

189-
#synchronous_standby_names = '' # standby servers that provide sync rep
190-
# comma-separated list of application_name from standby(s);
191-
# '*' = all
188+
#------------------------------------------------------------------------------
189+
# REPLICATION
190+
#------------------------------------------------------------------------------
192191

192+
# - Master Server -
193+
194+
# These settings are ignored on a standby server
193195

194196
#max_wal_senders = 0 # max number of walsender processes
195197
# (change requires restart)
196198
#wal_sender_delay = 1s # walsender cycle time, 1-10000 milliseconds
197199
#wal_keep_segments = 0 # in logfile segments, 16MB each; 0 disables
198200
#vacuum_defer_cleanup_age = 0 # number of xacts by which cleanup is delayed
199-
#replication_timeout = 60s # in milliseconds, 0 is disabled
201+
#replication_timeout = 60s # in milliseconds; 0 disables
202+
#synchronous_standby_names = '' # standby servers that provide sync rep
203+
# comma-separated list of application_name
204+
# from standby(s); '*' = all
200205

201206
# - Standby Servers -
202207

208+
# These settings are ignored on a master server
209+
203210
#hot_standby = off # "on" allows queries during recovery
204211
# (change requires restart)
205-
#hot_standby_feedback = off # info from standby to prevent query conflicts
206212
#max_standby_archive_delay = 30s # max delay before canceling queries
207213
# when reading WAL from archive;
208214
# -1 allows indefinite delay
209215
#max_standby_streaming_delay = 30s # max delay before canceling queries
210216
# when reading streaming WAL;
211217
# -1 allows indefinite delay
212-
#wal_receiver_status_interval = 10s # replies at least this often, 0 disables
218+
#wal_receiver_status_interval = 10s # send replies at least this often
219+
# 0 disables
220+
#hot_standby_feedback = off # send info from standby to prevent
221+
# query conflicts
213222

214223

215224
#------------------------------------------------------------------------------

src/include/utils/guc_tables.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,9 @@ enum config_group
6767
WAL_SETTINGS,
6868
WAL_CHECKPOINTS,
6969
WAL_ARCHIVING,
70-
WAL_REPLICATION,
71-
WAL_STANDBY_SERVERS,
70+
REPLICATION,
71+
REPLICATION_MASTER,
72+
REPLICATION_STANDBY,
7273
QUERY_TUNING,
7374
QUERY_TUNING_METHOD,
7475
QUERY_TUNING_COST,

0 commit comments

Comments
 (0)