diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index 54719e40a5..842558d673 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -1844,9 +1844,9 @@ SET ENABLE_SEQSCAN TO OFF; archive_mode and archive_command are separate variables so that archive_command can be changed without leaving archiving mode. - This parameter can only be set at server start. wal_level - must be set to archive or hot_standby to - enable archive_mode. + This parameter can only be set at server start. + archive_mode cannot be enabled when + wal_level is set to minimal. @@ -1911,7 +1911,10 @@ SET ENABLE_SEQSCAN TO OFF; files. Therefore, it is unwise to use a very short archive_timeout — it will bloat your archive storage. archive_timeout settings of a minute or so are - usually reasonable. This parameter can only be set in the + usually reasonable. You should consider using streaming replication, + instead of archiving, if you want data to be copied off the master + server more quickly than that. + This parameter can only be set in the postgresql.conf file or on the server command line. @@ -1920,14 +1923,32 @@ SET ENABLE_SEQSCAN TO OFF; - - Streaming Replication + + + + Replication + + + These settings control the behavior of the built-in + streaming replication feature (see + ). + Some parameters must be set on the master server, while others must be + set on the standby server(s) that will receive replication data. + + + + Master Server - These settings control the behavior of the built-in - streaming replication feature. - These parameters would be set on the primary server that is + These parameters can be set on the primary server that is to send replication data to one or more standby servers. + Note that in addition to these parameters, + must be set appropriately on the master + server, and you will typically want to enable WAL archiving as + well (see ). + The values of these parameters on standby servers are irrelevant, + although you may wish to set them there in preparation for the + possibility of a standby becoming the master. @@ -1995,7 +2016,7 @@ SET ENABLE_SEQSCAN TO OFF; pg_xlog; the system might need to retain more segments for WAL archival or to recover from a checkpoint. If wal_keep_segments is zero (the default), the system - doesn't keep any extra segments for standby purposes, and the number + doesn't keep any extra segments for standby purposes, so the number of old WAL segments available to standby servers is a function of the location of the previous checkpoint and status of WAL archiving. This parameter has no effect on restartpoints. @@ -2057,20 +2078,7 @@ SET ENABLE_SEQSCAN TO OFF; - - - - Synchronous Replication - - - These settings control the behavior of the built-in - synchronous replication feature. - These parameters would be set on the primary server that is - to send replication data to one or more standby servers. - - - synchronous_standby_names (string) @@ -2078,29 +2086,37 @@ SET ENABLE_SEQSCAN TO OFF; - Specifies a priority ordered list of standby names that can offer - synchronous replication. At any one time there will be at most one - synchronous standby that will wake sleeping users following commit. - The synchronous standby will be the first named standby that is - both currently connected and streaming in real-time to the standby - (as shown by a state of STREAMING). Other standby servers - with listed later will become potential synchronous standbys. - If the current synchronous standby disconnects for whatever reason - it will be replaced immediately with the next highest priority standby. + Specifies a comma-separated list of standby names that can support + synchronous replication, as described in + . + At any one time there will be at most one active synchronous standby; + transactions waiting for commit will be allowed to proceed after + this standby server confirms receipt of their data. + The synchronous standby will be the first standby named in this list + that is both currently connected and streaming data in real-time + (as shown by a state of STREAMING in the + + pg_stat_replication view). + Other standby servers appearing later in this list represent potential + synchronous standbys. + If the current synchronous standby disconnects for whatever reason, + it will be replaced immediately with the next-highest-priority standby. Specifying more than one standby name can allow very high availability. - The standby name is currently taken as the application_name setting of the - standby, as set in the primary_conninfo on the standby. Names are - not enforced for uniqueness. In case of duplicates one of the standbys - will be chosen to be the synchronous standby, though exactly which - one is indeterminate. - The special entry * matches any application_name, including - the default application name of walreceiver. + The name of a standby server for this purpose is the + application_name setting of the standby, as set in the + primary_conninfo of the standby's walreceiver. There is + no mechanism to enforce uniqueness. In case of duplicates one of the + matching standbys will be chosen to be the synchronous standby, though + exactly which one is indeterminate. + The special entry * matches any + application_name, including the default application name + of walreceiver. - If no synchronous standby names are specified, then synchronous - replication is not enabled and transaction commit will never wait for + If no synchronous standby names are specified here, then synchronous + replication is not enabled and transaction commits will not wait for replication. This is the default configuration. Even when synchronous replication is enabled, individual transactions can be configured not to wait for replication by setting the @@ -2117,12 +2133,13 @@ SET ENABLE_SEQSCAN TO OFF; - - Standby Servers + + Standby Servers These settings control the behavior of a standby server that is - to receive replication data. + to receive replication data. Their values on the master server + are irrelevant. @@ -2213,12 +2230,14 @@ SET ENABLE_SEQSCAN TO OFF; Specifies the minimum frequency for the WAL receiver process on the standby to send information about replication progress - to the primary, where they can be seen using the - pg_stat_replication view. The standby will report + to the primary, where it can be seen using the + + pg_stat_replication view. The standby will report the last transaction log position it has written, the last position it - has flushed to disk, and the last position it has applied. The parameter + has flushed to disk, and the last position it has applied. + This parameter's value is the maximum interval, in seconds, between reports. Updates are - sent each time the write or flush positions changed, or at least as + sent each time the write or flush positions change, or at least as often as specified by this parameter. Thus, the apply position may lag slightly behind the true position. Setting this parameter to zero disables status updates completely. This parameter can only be set in diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 7b7d26089d..5a0e94f801 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -551,10 +551,12 @@ const char *const config_group_names[] = gettext_noop("Write-Ahead Log / Checkpoints"), /* WAL_ARCHIVING */ gettext_noop("Write-Ahead Log / Archiving"), - /* WAL_REPLICATION */ - gettext_noop("Write-Ahead Log / Streaming Replication"), - /* WAL_STANDBY_SERVERS */ - gettext_noop("Write-Ahead Log / Standby Servers"), + /* REPLICATION */ + gettext_noop("Replication"), + /* REPLICATION_MASTER */ + gettext_noop("Replication / Master Server"), + /* REPLICATION_STANDBY */ + gettext_noop("Replication / Standby Servers"), /* QUERY_TUNING */ gettext_noop("Query Tuning"), /* QUERY_TUNING_METHOD */ @@ -1357,7 +1359,7 @@ static struct config_bool ConfigureNamesBool[] = }, { - {"hot_standby", PGC_POSTMASTER, WAL_STANDBY_SERVERS, + {"hot_standby", PGC_POSTMASTER, REPLICATION_STANDBY, gettext_noop("Allows connections and queries during recovery."), NULL }, @@ -1367,7 +1369,7 @@ static struct config_bool ConfigureNamesBool[] = }, { - {"hot_standby_feedback", PGC_SIGHUP, WAL_STANDBY_SERVERS, + {"hot_standby_feedback", PGC_SIGHUP, REPLICATION_STANDBY, gettext_noop("Allows feedback from a hot standby to the primary that will avoid query conflicts."), NULL }, @@ -1534,7 +1536,7 @@ static struct config_int ConfigureNamesInt[] = }, { - {"max_standby_archive_delay", PGC_SIGHUP, WAL_STANDBY_SERVERS, + {"max_standby_archive_delay", PGC_SIGHUP, REPLICATION_STANDBY, gettext_noop("Sets the maximum delay before canceling queries when a hot standby server is processing archived WAL data."), NULL, GUC_UNIT_MS @@ -1545,7 +1547,7 @@ static struct config_int ConfigureNamesInt[] = }, { - {"max_standby_streaming_delay", PGC_SIGHUP, WAL_STANDBY_SERVERS, + {"max_standby_streaming_delay", PGC_SIGHUP, REPLICATION_STANDBY, gettext_noop("Sets the maximum delay before canceling queries when a hot standby server is processing streamed WAL data."), NULL, GUC_UNIT_MS @@ -1556,7 +1558,7 @@ static struct config_int ConfigureNamesInt[] = }, { - {"wal_receiver_status_interval", PGC_SIGHUP, WAL_STANDBY_SERVERS, + {"wal_receiver_status_interval", PGC_SIGHUP, REPLICATION_STANDBY, gettext_noop("Sets the maximum interval between WAL receiver status reports to the primary."), NULL, GUC_UNIT_S @@ -1841,7 +1843,7 @@ static struct config_int ConfigureNamesInt[] = }, { - {"vacuum_defer_cleanup_age", PGC_SIGHUP, WAL_REPLICATION, + {"vacuum_defer_cleanup_age", PGC_SIGHUP, REPLICATION_MASTER, gettext_noop("Number of transactions by which VACUUM and HOT cleanup should be deferred, if any."), NULL }, @@ -1901,7 +1903,7 @@ static struct config_int ConfigureNamesInt[] = }, { - {"wal_keep_segments", PGC_SIGHUP, WAL_REPLICATION, + {"wal_keep_segments", PGC_SIGHUP, REPLICATION_MASTER, gettext_noop("Sets the number of WAL files held for standby servers."), NULL }, @@ -1969,7 +1971,7 @@ static struct config_int ConfigureNamesInt[] = { /* see max_connections */ - {"max_wal_senders", PGC_POSTMASTER, WAL_REPLICATION, + {"max_wal_senders", PGC_POSTMASTER, REPLICATION_MASTER, gettext_noop("Sets the maximum number of simultaneously running WAL sender processes."), NULL }, @@ -1979,7 +1981,7 @@ static struct config_int ConfigureNamesInt[] = }, { - {"wal_sender_delay", PGC_SIGHUP, WAL_REPLICATION, + {"wal_sender_delay", PGC_SIGHUP, REPLICATION_MASTER, gettext_noop("WAL sender sleep time between WAL replications."), NULL, GUC_UNIT_MS @@ -1990,7 +1992,7 @@ static struct config_int ConfigureNamesInt[] = }, { - {"replication_timeout", PGC_SIGHUP, WAL_REPLICATION, + {"replication_timeout", PGC_SIGHUP, REPLICATION_MASTER, gettext_noop("Sets the maximum time to wait for WAL replication."), NULL, GUC_UNIT_MS @@ -2954,7 +2956,7 @@ static struct config_string ConfigureNamesString[] = }, { - {"synchronous_standby_names", PGC_SIGHUP, WAL_REPLICATION, + {"synchronous_standby_names", PGC_SIGHUP, REPLICATION_MASTER, gettext_noop("List of names of potential synchronous standbys."), NULL, GUC_LIST_INPUT diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 229d0e86a9..940329377a 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -184,32 +184,41 @@ #archive_timeout = 0 # force a logfile segment switch after this # number of seconds; 0 disables -# - Streaming Replication - Server Settings -#synchronous_standby_names = '' # standby servers that provide sync rep - # comma-separated list of application_name from standby(s); - # '*' = all +#------------------------------------------------------------------------------ +# REPLICATION +#------------------------------------------------------------------------------ +# - Master Server - + +# These settings are ignored on a standby server #max_wal_senders = 0 # max number of walsender processes # (change requires restart) #wal_sender_delay = 1s # walsender cycle time, 1-10000 milliseconds #wal_keep_segments = 0 # in logfile segments, 16MB each; 0 disables #vacuum_defer_cleanup_age = 0 # number of xacts by which cleanup is delayed -#replication_timeout = 60s # in milliseconds, 0 is disabled +#replication_timeout = 60s # in milliseconds; 0 disables +#synchronous_standby_names = '' # standby servers that provide sync rep + # comma-separated list of application_name + # from standby(s); '*' = all # - Standby Servers - +# These settings are ignored on a master server + #hot_standby = off # "on" allows queries during recovery # (change requires restart) -#hot_standby_feedback = off # info from standby to prevent query conflicts #max_standby_archive_delay = 30s # max delay before canceling queries # when reading WAL from archive; # -1 allows indefinite delay #max_standby_streaming_delay = 30s # max delay before canceling queries # when reading streaming WAL; # -1 allows indefinite delay -#wal_receiver_status_interval = 10s # replies at least this often, 0 disables +#wal_receiver_status_interval = 10s # send replies at least this often + # 0 disables +#hot_standby_feedback = off # send info from standby to prevent + # query conflicts #------------------------------------------------------------------------------ diff --git a/src/include/utils/guc_tables.h b/src/include/utils/guc_tables.h index a1ca012ef9..7f8c69fcf4 100644 --- a/src/include/utils/guc_tables.h +++ b/src/include/utils/guc_tables.h @@ -67,8 +67,9 @@ enum config_group WAL_SETTINGS, WAL_CHECKPOINTS, WAL_ARCHIVING, - WAL_REPLICATION, - WAL_STANDBY_SERVERS, + REPLICATION, + REPLICATION_MASTER, + REPLICATION_STANDBY, QUERY_TUNING, QUERY_TUNING_METHOD, QUERY_TUNING_COST,