This document describes the parameters related to the replication category in the system configuration parameters.
Note!
To ensure system stability and security, please exercise caution when manually modifying the relevant parameters.
These settings control the behavior of stream replication features. The server can be either a master server or a standby server. The master server can send data, while the standby server is always the recipient of replicated data. These parameters are primarily used for sending servers and standby servers, although some are only meaningful on the master server.
These parameters must be set on the Master and any Standby that will send replica data.
Specifies the maximum number of replication slots that the server can support.
replica
or higher.Data type | Default value | Valid range | Setting category |
---|---|---|---|
int | 10 | 1 ~ 262143 | segments;system;restart |
Set the maximum WAL size (MB) that can be retained by the replication slot.
-1
, which disables this feature.Data type | Default value | Value range | Setting category |
---|---|---|---|
int | -1 | -1 ~ INT_MAX/1024 | segments;system;reload |
Specify the maximum number of concurrent connections from standby servers or streaming base backup clients (i.e., the maximum number of WAL send processes that can run simultaneously).
replica
or higher to allow connections from standby servers.Data type | Default value | Valid range | Setting category |
---|---|---|---|
int | 10 | 0 ~ 262143 | segments;system;restart |
Record the commit time of transactions.
| Data type | Default value | Setting category | | --- | --- | --- | --- | | boolean | off | segments;system;restart |
When this parameter is set to on
, new WAL files are padded with zeros.
off
, only the last bytes are written when the file is created, so it has an expected size.Data type | Default value | Setting category |
---|---|---|
boolean | on | segments;session;reload;superuser |
Specifies the minimum number of past log file segments that can be retained in the pg_wal
directory when a standby server needs to obtain log segments for streaming replication.
wal_keep_segments
segments, the sending server may remove a WAL segment that the standby server still needs, in which case the replication connection will be interrupted. Ultimately, the downstream connection will also fail (however, if WAL archiving is in use, the standby server can recover by retrieving segments from the archive).pg_wal
; the system may need to retain more segments for WAL archiving or recovery from a checkpoint.0
(default), the system does not retain any extra segments for standby purposes, so the number of old WAL segments available to the standby server is a function of the previous checkpoint position and the WAL archiving status.Data type | Default value | Value range | Setting category |
---|---|---|---|
int | 64 | 0 ~ INT_MAX | segments;system;reload |
Recycle WAL files.
on
, WAL files are recycled by renaming them to avoid creating new files.Data type | Default value | Setting category |
---|---|---|
boolean | on | segments;session;reload;superuser |
Disconnect replication connections that have been inactive for longer than this specified time (in milliseconds).
0
disables the timeout mechanism.300000 milliseconds
, equivalent to 5 minutes.Data type | Default value | Value range | Setting category |
---|---|---|---|
int | 300000 | 0 ~ INT_MAX | segments;session;reload;superuser |
This section is skipped on the Standby server.
Note!
In addition to these parameters, the appropriate wal_level must be set on the Master server, and optional WAL archiving must also be enabled.
This parameter specifies a list of standby servers that support synchronous replication.
application_name
set in their connection information, separated by commas in the list.primary_conninfo
setting. If set, the default is the cluster_name
setting; otherwise, it is walreceiver
.‘*’
matches any standby name.This parameter uses one of the following syntaxes to specify a list of standby servers:
[FIRST] num_sync ( standby_name [, ...] )
ANY num_sync ( standby_name [, ...] )
standby_name [, ...]
num_sync
is the number of synchronous standby servers that the transaction must wait for a response from, and standby_name
is the name of a standby server. FIRST
and ANY
specify the method for selecting synchronous standbys from the listed servers.FIRST
combined with num_sync
specifies a priority-based synchronous replication, causing transactions to wait for commit until their WAL records are replicated to the num_sync
synchronous standby servers selected based on priority. For example, setting FIRST 3 (s1, s2, s3, s4)
will cause each commit to wait for responses from the three highest-priority standby servers, which are selected from the standby servers s1, s2, s3, and s4.FIRST
is optional.ANY
combined with num_sync
specifies a synchronization-based replication method, causing transaction commits to wait until their WAL records are replicated to at least num_sync
of the listed standby servers. For example, setting ANY 3 (s1, s2, s3, s4)
will cause each commit to proceed immediately after receiving responses from any three of the standby servers s1, s2, s3, and s4.FIRST
and ANY
are case-insensitive. If these keywords are used as standby server names, their standby_name
must be enclosed in double quotes.FIRST
and num_sync
set to 1. For example, FIRST 1 (s1, s2)
and s1, s2 have the same meaning: either s1 or s2 will be selected as the synchronized standby server.standby_name
should be in the form of a valid SQL identifier, unless it is *
. You can use double quotes if necessary. However, note that when comparing standby_name
and standby application names, case sensitivity is ignored (regardless of whether double quotes are used).
If no synchronous standby names are specified here, synchronous replication cannot be 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 synchronous_commit parameter to local
or off
.Data Type | Default Value | Setting Category |
---|---|---|
string | segments;system;reload |
Specify how long (in terms of transaction count) to delay VACUUM
and HOT
updates before clearing dead row versions.
hot_standby_feedback
on the standby server as an alternative to using this parameter.old_snapshot_threshold
from being cleared.Data type | Default value | Value range | Setting category |
---|---|---|---|
int | 0 | 0 to 1000000 | segments; system; reload |
This section will be skipped on the Master server.
Specify whether it is possible to connect and run queries during recovery.
Data type | Default value | Setting category |
---|---|---|
boolean | off | segments; system; restart |
Specify whether a hot standby server will send feedback to the primary server or upstream standby server regarding queries currently being executed on the standby server.
wal_receiver_status_interval
cycle.old_snapshot_threshold
on the primary server. A snapshot on the standby server that exceeds the primary server's age threshold may become unavailable, leading to transaction cancellations on the standby server. This is because old_snapshot_threshold
imposes an absolute limit on how long dead rows can exist, thereby preventing the configuration of a standby server from being compromised.Data Type | Default Value | Setting Category |
---|---|---|
boolean | off | segments;system;reload |
When the hot standby server is active, this parameter determines the amount of time (in milliseconds) the standby server should wait before canceling standby queries that conflict with upcoming WAL items. For more details, see Handling Query Conflicts.
max_standby_archive_delay
can be applied.-1
allows the standby server to wait indefinitely until the conflicting query completes.max_standby_archive_delay
is different from the maximum time a query can run before being canceled; it represents the maximum total time allowed for applying any WAL segment data. Therefore, if a query prior to the WAL segment causes significant delay, subsequent conflicting queries will have less time.Data type | Default value | Value range | Setting category |
---|---|---|---|
int | 30000 | -1 ~ INT_MAX | segments;system;reload |
When the hot standby server is active, this parameter determines the amount of time (in milliseconds) the standby server should wait before canceling standby queries that conflict with upcoming WAL items. For more details, see Handling Query Conflicts.
max_standby_streaming_delay
can be applied.-1
allows the standby server to wait indefinitely until the conflicting query completes.Data type | Default value | Valid range | Setting category |
---|---|---|---|
int | 30000 | -1 ~ INT_MAX | segments;system;reload |
Specify the connection string for the backup server used to connect to the sending server. - If any options are not specified in this string, the corresponding environment variables will be checked. If the environment variables are also not set, the default values will be used.
primary_conninfo
string or in a separate ~/.pgpass
file on the backup server (using replication
as the database name).primary_conninfo
string.Data type | Default value | Setting category |
---|---|---|
string | segments;system;restart;superuser |
When selectively specifying a connection to the sending server via stream replication, use an existing replication slot to control resource removal on the upstream node.
primary_conninfo
is not set, this setting is invalid.Data type | Default value | Setting category |
---|---|---|
string | segments;system;restart |
Specify a trigger file whose existence will end the recovery state in the standby machine.
pg_ctl promote
or call pg_promote
to promote the standby machine.Data type | Default value | Setting category |
---|---|---|
string | segments;system;reload |
By default, the standby server will recover WAL records from the sending server as soon as possible.
Note: The delay is calculated based on the timestamp when the WAL was written on the primary server and the current time on the standby server. Network latency or transmission delays caused by cascading replication configurations may significantly reduce the actual wait time.
hot_standby_feedback
, which may cause the primary server to swell; use with caution when using both together.0
, meaning no delay is added.Note!
Whensynchronous_commit
is set toremote_apply
, synchronous replication is affected by this setting, and eachCOMMIT
must wait to be applied.
Data type | Default value | Valid range | Setting category |
---|---|---|---|
int | 0 | 0 ~ INT_MAX | segments;system;reload |
Specify the minimum frequency (in seconds) at which the WAL receiver process on the standby server sends information about replication progress to the primary server or upstream standby server.
0
completely disables status updates.Data type | Default value | Valid range | Setting category |
---|---|---|---|
int | 10 | 0 ~ INT_MAX/1000 | segments;system;reload |
Stop replicating links that have been inactive for longer than the value specified by this parameter (in milliseconds).
0
indicates that the feature is disabled.Data type | Default value | Value range | Setting category |
---|---|---|---|
int | 60000 | 0 ~ INT_MAX | segments;system;reload |
Specifies how long (in milliseconds) the standby server should wait before retrying to retrieve WAL data when WAL data is unavailable from any source (stream replication, local pg_wal
, or WAL archive).
Data type | Default value | Valid range | Setting category |
---|---|---|---|
int | 5000 | 1 ~ INT_MAX | segments;system;reload |
These parameters control the behavior of logical replication subscribers. Their values on the publisher are irrelevant.
Note!
The configuration parameterswal_receiver_timeout
,wal_receiver_status_interval
, andwal_retrieve_retry_interval
also affect logical replication workers.
Specify the maximum number of logical replication workers. This includes both application workers and table synchronization workers.
max_worker_processes
.Data type | Default value | Value range | Setting category |
---|---|---|---|
int | 4 | 0 ~ 262143 | segments;system;restart |
The maximum number of synchronous workers per subscription.
max_logical_replication_workers
.数据类型 | 默认值 | 取值范围 | 设置分类 |
---|---|---|---|
int | 2 | 0 ~ 262143 | segments;system;reload |