Updated on 2024-08-20 GMT+08:00

PG_STAT_REPLICATION

PG_STAT_REPLICATION displays information about the log synchronization thread, such as the locations where the sender sends logs and where the receiver receives logs. For details about the columns, see Table 1.

Table 1 PG_STAT_REPLICATION columns

Name

Type

Description

pid

bigint

PID of the thread

usesysid

oid

User system ID.

usename

name

Username

application_name

text

Program name

client_addr

inet

Client address

client_hostname

text

Client name

client_port

integer

Port of the client

backend_start

timestamp with time zone

Start time of the program

state

text

Status of the log synchronization thread:

  • startup: The thread is being started.
  • catchup: The thread is establishing a connection between the standby node and the primary node.
  • streaming: The thread has established a connection between the standby node and the primary node and is replicating data streams.
  • backup: The thread is sending a backup.
  • stopping: The thread is being stopped.

sender_sent_location

text

Location where the transmit sends logs

receiver_write_location

text

Location where the receive end writes logs

receiver_flush_location

text

Location where the receive end flushes logs

receiver_replay_location

text

Location where the receive end replays logs

sync_priority

integer

Priority of synchronous duplication (0 indicates asynchronization.)

sync_state

text

Synchronization state:

  • async: asynchronous replication.
  • sync: synchronous replication.
  • potential: The standby node is asynchronous currently, but if a current synchronization node fails, the standby node becomes synchronous.
  • quorum: switches between the synchronous and asynchronous states to ensure that there are more than a certain number of synchronous standby servers. Generally, the number of synchronous standby servers is (n+1)/2-1, where n indicates the total number of copies. Whether the standby server is synchronous depends on whether logs are received first. For details, see the description of the synchronous_standby_names parameter.