Monitoring Database Replication Progress via SHOW REPLICA STATUS

Core Purpose

The SHOW REPLICA STATUS instruction serves as a diagnostic utility for evaluating Write-Ahead Log (WAL) transmission health. It surfaces granular synchronization metrics, tracking byte-level offsets between the originating host and consuming standby instances.

Operational Constraints

  • Invocation is restricted exclusively to the authoritative (primary) database node.
  • Data projection aligns precisely with the underlying pg_stat_get_wal_senders() system catalog.

Syntax Blueprint

SHOW {SLAVE | REPLICA} STATUS [FOR CHANNEL channel_identifier]

Parameter Breakdown

  • {SLAVE | REPLICA}: Semantic aliases functioning identically within the parser.
  • [FOR CHANNEL channel_identifier]: Optional predicate enabling partial string matching against transport descriptors. Typically leveraged for isolating routes defined by subnet masks, port configurations, or custom tunnel labels.

Response Attributes

  • pid: Operating system thread identifier managing the WAL dispatch process.
  • sender_pid: Internal lightweight process handle mapped to the dispatcher.
  • local_role: Architectural designation of the executing host.
  • peer_role: Designation of the linked secondary node.
  • peer_state: Runtime posture of the target replica.
  • state: Lifecycle phase of the sender daemon.
  • catchup_start / catchup_end: Temporal boundaries defining the initial data resynchronization window.
  • sender_sent_location: Highest Log Sequence Number (LSN) queued for network delivery.
  • sender_write_location: Maximum LSN committed to volatile memory buffers on the source.
  • sender_flush_location: LSN checkpoint verified as durable on primary storage subsystems.
  • sender_replay_location: LSN processed by the primary transaction engine.
  • receiver_received_location: LSN acknowledged up on arrival at the destination stack.
  • receiver_write_location: Buffer stage LSN recorded locally on the standby.
  • receiver_flush_location: Persistent storage confirmation point on the replica side.
  • receiver_replay_location: Transaction application frontier on the standby instance.
  • sync_percent: Calculated delta representing replication fidelity.
  • sync_state: Consistency classification (e.g., Sync, Async, Local).
  • sync_priority: Numerical weight assigned to automatic failover election protocols.
  • sync_most_available: Cluster policy indicator governing continuous operation guarantees.
  • channel: Endpoint topology mapping source-to-destination connectivity details.

Execution Scenarios

Initiate a global sweep to assess all active replication tunnels:

openGauss=# SHOW REPLICA STATUS;
Field Extracted Value
pid 90234567890123
sender_pid 55201
local_role Primary
peer_role Standby
peer_state Streaming
state Streaming
catchup_start 2024-06-12 08:30:05.441+00
catchup_end 2024-06-12 08:30:06.112+00
sender_sent_location 2/F10C040
sender_write_location 2/F10BF20
sender_flush_location 2/F10BE00
sender_replay_location 2/F10B000
receiver_received_location 2/F10BF20
receiver_write_location 2/F10BE00
receiver_flush_location 2/F10BD80
receiver_replay_location 2/F10BB00
sync_percent 94%
sync_state Local
sync_priority 3
sync_most_available Off
channel 172.16.0.8:5432-->172.16.0.9:51402

To restrict diagnostics to a specific network segment, apply substring filtering within the channel clause:

openGauss=# SHOW SLAVE STATUS FOR CHANNEL '16.0.8';
Field Extracted Value
pid 90234567890123
sender_pid 55201
local_role Primary
peer_role Standby
peer_state Streaming
state Streaming
catchup_start 2024-06-12 08:30:05.441+00
catchup_end 2024-06-12 08:30:06.112+00
sender_sent_location 2/F10C040
sender_write_location 2/F10BF20
sender_flush_location 2/F10BE00
sender_replay_location 2/F10B000
receiver_received_location 2/F10BF20
receiver_write_location 2/F10BE00
receiver_flush_location 2/F10BD80
receiver_replay_location 2/F10BB00
sync_percent 94%
sync_state Local
sync_priority 3
sync_most_available Off
channel 172.16.0.8:5432-->172.16.0.9:51402

Evaluating replication lag requires calculating the hexadecimal difference between sender_sent_location and receiver_replay_location. A continuously expanding delta signals network congestion or receiver-side bottleneck, necessitating capacity review or workload redistribution.

Tags: openGauss WALTransmission StreamFailover DatabaseMonitoring SynchronizationMetrics

Posted on Thu, 24 Sep 2026 16:27:08 +0000 by DannyM