Updated on 2023-10-23 GMT+08:00

Standby Server

hot_standby

Parameter description: Specifies whether the standby server is allowed to accept connections and queries after it is restored to the minrecovery point.

This parameter is a POSTMASTER parameter. Set it based on instructions provided in Table 1.

  • If this parameter is set to on, wal_level must be set to hot_standby or higher. Otherwise, the database startup fails.
  • In a distributed system, hot_standby cannot be set to off, because this setting can affect other features of the HA system.
  • If the hot_standby parameter was disabled and the wal_level parameter was set to a value smaller than the value of hot_standby, perform the following operations to ensure that the logs to be replayed on the standby node can be queried on the standby node before enabling the hot_standby parameter again:
    1. Change the value of wal_level of the primary and standby nodes to the value of hot_standby or a higher value, and restart the instances for the change to take effect.
    2. Perform the checkpoint operation on the primary node and query the pg_stat_get_wal_senders() function to ensure that the value of receiver_replay_location of each standby node is the same as that of sender_flush_location of the primary node. Ensure that the value adjustment of wal_level is synchronized to the standby nodes and takes effect, and the standby nodes do not need to replay low-level logs.
    3. Set the hot_standby parameter of the primary and standby nodes to on, and restart the instances for the setting to take effect.

Value range: Boolean

  • on: allowed.
  • off: not allowed.

Default value: on

max_standby_archive_delay

Parameter description: Specifies the wait period before queries on a standby server are canceled when the queries conflict with WAL processing and archiving in hot standby mode.

This parameter is a SIGHUP parameter. Set it based on instructions provided in Table 1.

–1 indicates that the standby server waits until the conflicting queries are complete.

Value range: an integer ranging from –1 to 2147483647. The unit is ms.

Default value: 3s (3000 ms)

max_standby_streaming_delay

Parameter description: Specifies the wait period before queries on a standby server are canceled when the queries conflict with WAL data receiving through streaming replication in hot standby mode.

This parameter is a SIGHUP parameter. Set it based on instructions provided in Table 1.

–1 indicates that the standby server waits until the conflicting queries are complete.

Value range: an integer ranging from –1 to 2147483647. The unit is ms.

Default value: 3s (3000 ms)

wal_receiver_status_interval

Parameter description: Specifies the maximum interval for notifying the primary server of the WAL Receiver status.

This parameter is a SIGHUP parameter. Set it based on instructions provided in Table 1.

If this parameter is set to 0, the standby server does not send information, such as the log receiving location, to the primary server. As a result, the transaction commit on the primary server may be blocked, and the switchover may fail. In normal service scenarios, you are advised not to set this parameter to 0.

Value range: an integer ranging from 0 to 2147483. The unit is s.

Default value: 5s

hot_standby_feedback

Parameter description: Specifies whether a standby server is allowed to send the result of a query performed on it to the primary server, preventing a query conflict.

This parameter is a SIGHUP parameter. Set it based on instructions provided in Table 1.

Value range: Boolean

  • on indicates that the standby server is allowed to send the result of a query performed on it to the primary server.
  • off indicates that the standby server is not allowed to send the result of a query performed on it to the primary server.

Default value: off

wal_receiver_timeout

Parameter description: Specifies the maximum wait period for a standby server to receive data from the primary server.

This parameter is a SIGHUP parameter. Set it based on instructions provided in Table 1.

Value range: an integer ranging from 0 to 2147483647. The unit is ms.

Default value: 6s (6000 ms)

wal_receiver_connect_timeout

Parameter description: Specifies the timeout period for a standby server to connect to the primary server.

This parameter is a SIGHUP parameter. Set it based on instructions provided in Table 1.

Value range: an integer ranging from 0 to 2147483. The unit is s.

Default value: 2s

wal_receiver_connect_retries

Parameter description: Specifies the maximum attempts that a standby server connects to the primary server

This parameter is a SIGHUP parameter. Set it based on instructions provided in Table 1.

Value range: an integer ranging from 1 to 2147483647

Default value: 1

wal_receiver_buffer_size

Parameter description: Specifies the memory buffer size for the standby and secondary servers to store the received XLOG files.

This parameter is a POSTMASTER parameter. Set it based on instructions provided in Table 1.

Value range: an integer ranging from 4096 to 1047552. The unit is KB.

Default value: 64 MB (65536 KB)

primary_slotname

Parameter description: Specifies the slot name of the primary server corresponding to a standby server. This parameter is used for the mechanisms to verify the primary-standby relationship and delete WALs.

This parameter is a SIGHUP parameter. Set it based on instructions provided in Table 1.

Value range: a string

Default value: empty

enable_redo_atomic_operation

Parameter description: Specifies whether to use atomic operations or spinlocks to update the LSN of the current thread when parallel playback is enabled.

This parameter is a POSTMASTER parameter. Set it based on instructions provided in Table 1.

Value range: Boolean

  • on indicates that atomic operations are used for update.
  • off indicates that spinlocks are used for update.

Default value: on