Technologies/PostgreSQL/postgresql.replication.replay_lsn_delay
PostgreSQLPostgreSQLMetric

postgresql.replication.replay_lsn_delay

Replication replay LSN delay
Dimensions:None
Available on:Native (1)DatadogDatadog (1)
Interface Metrics (2)
Native
replay_lsn statistic from pg_stat_replication
Dimensions:None
DatadogDatadog
The delay in bytes between the current WAL position and the last location replayed by the standby server
Dimensions:None

Technical Annotations (18)

Configuration Parameters (6)
wal_keep_segmentsrecommended: increase from default
number of WAL segments to retain in pg_xlog directory
max_wal_sendersrecommended: increase from default
maximum concurrent WAL sender processes allowed
archive_moderecommended: on
enable WAL archiving to preserve segments
archive_commandrecommended: configured to alternate path
command to archive WAL files to backup location
max_standby_streaming_delayrecommended: 30s
maximum time standby waits before canceling queries during replay
hot_standby_feedbackrecommended: on
prevents query cancellations on standby by informing primary
CLI Commands (6)
SELECT client_addr, state, sent_lsn, write_lsn, flush_lsn, replay_lsn, pg_wal_lsn_diff(sent_lsn, replay_lsn) AS lag_bytes FROM pg_stat_replication;monitoring
SELECT now() - pg_last_xact_replay_timestamp() AS replication_lag;monitoring
ALTER SYSTEM SET max_wal_senders = 10;remediation
ALTER SYSTEM SET wal_keep_segments = 64;remediation
ALTER SYSTEM SET max_standby_streaming_delay = '30s';remediation
ALTER SYSTEM SET hot_standby_feedback = on;remediation
Technical References (6)
WALcomponentWrite-Ahead Loggingconceptpg_xlogfile pathcheckpointconceptpg_stat_replicationcomponentstreaming replicationconcept
Related Insights (3)
WAL segment deletion causes replication lag and requires replica rebuildcritical
Replication lag causing stale reads on standbywarning
Replication lag causes stale reads on replicaswarning

Streaming replication lag between primary and replica nodes increases, causing replicas to serve stale data. High lag indicates replica cannot keep up with primary write volume, network issues, or resource constraints on replica.