ClusterEyeClusterEye
Request DemoStart free trial
Availability and replication

PostgreSQL replication lag: why a replica is falling behind

On the Replication tab read the health summary, the replica cards, the send-write-flush-replay pipeline, the lag chart and the replication slots to find at which stage and why lag builds up; on a Patroni cluster also check failover readiness.

Scope

Engines
PostgreSQL
Roles
AdminDBAViewer
ClusterEye
ClusterEye 1.6.50 and laterWritten from the product code
Prerequisites
  • The Replication tab exists on every PostgreSQL node and viewing it is open to all monitoring roles (Admin, DBA, Viewer). On a primary node you see the replicas, on a standby node the WAL receiver state; with no replica attached the page says 'Not replicating' and gives no score.
  • The 'Patroni Management' tab opens only when the node is managed by Patroni (it is disabled with 'Patroni is not detected on this node') and needs a Pro or Enterprise licence. Switchover, Failover, Pause/Resume and the node actions need the Admin or DBA role; this guide only reads.

When this guide helps

  • postgresql replica is falling behind
  • postgresql replication lag alarm fired
  • why is the postgresql standby lagging
  • postgresql replication delay which stage
  • postgresql replication slot is retaining WAL
  • postgresql streaming replication stopped
  • patroni replica lag failover candidate

Steps

  1. Step 1: Observe → Performance Analyzer → PostgreSQL → Replication

    Do

    On the PostgreSQL Performance Analytics page pick the primary node first and open the Replication tab. Choose the time range at the top right (default 1h) and press 'Refresh' if needed.

    Look for

    In the header the role tag (PRIMARY / STANDBY / STANDALONE), 'Streaming · N replicas', 'N sync' / 'N async' and, where it applies, 'Partial data'; 'Updated … · auto 30s'. The line below: 'Colours are advisory (...)' and 'Alarm fires at ...'. On the left the 'Replication health' card: a score ring, 'Healthy' / 'Degraded' / 'Critical' and a checklist (All replicas streaming, Lag under 1s on all replicas or '<replica> lag Xs', WAL senders N / M in use, a slot line).

    How to read it

    The page refreshes every 30 seconds (a fixed past range does not refresh). The colour bands are advisory: in the code replica lag warns at ≥ 1 s and is critical at ≥ 5 s, and WAL behind warns at ≥ 100 MB and is critical at ≥ 1 GB. The 'Alarm fires at ...' line shows the alarm level that applies to this node (it adds '(global setting)' when the value comes from the global setting); thresholds are changed on the Settings page behind the 'Alarm thresholds' link. The health card grades replicas by their own state: a replica that is not streaming is a warning if it is in 'catchup' and critical in any other state; 'Configured sync standby not attached' is critical and says commits can wait on that standby while synchronous_commit is on; 'WAL senders N / M in use' turns to a warning at 80% use or more; 'max_wal_senders = 0' says replicas cannot connect. 'N of M replicas need attention' counts replicas in warning or critical. The score is shown on a primary only; on a standby the card shows 'Receiver down' or the WAL receiver state and the 'Replay delay'. The real lag numbers are in the cards below; this card tells you where to look.

  2. Step 2: Observe → Performance Analyzer → PostgreSQL → Replication

    Do

    Look at the replica boxes in the 'Topology' card (one box per replica on the primary). If needed open the same tab on the lagging standby node too.

    Look for

    In each box the name, a SYNC STANDBY / QUORUM STANDBY / REPLICA tag, the state (streaming, catchup ...), 'reply X.Xs ago' and write / flush / replay bars. On the link line a label such as 'ASYNC · 2.30s'. In the primary box 'CURRENT LSN' and 'WAL N/s'. On a standby node an 'UPSTREAM' box, a 'REPLAY · time' or 'DOWN' label and 'last message Ns ago'.

    How to read it

    The three bars measure the replica's write, flush and replay lag against the 1 s warning limit (a full bar = 1 s); the colour shows the replica's health and an unhealthy replica also shows a diagnostic sentence. The 'reply' time is the age of the last feedback from the replica: past 2 s it turns to the warning colour and past 10 s to critical. If the replica is in any state other than 'streaming' (for example catchup) or the 'reply' age keeps growing, the problem is in the transport and not in slow replay. The primary's 'WAL N/s' is the WAL generation rate; the agent samples about once a minute and the LSN in between is estimated and marked '≈ est.'. If you see write waits on the primary while no 'sync' standby is attached, look first at the 'Configured sync standby not attached' line from step 1.

  3. Step 3: Observe → Performance Analyzer → PostgreSQL → Replication

    Do

    Read the 'Pipeline' card and the 'Replication lag' chart next to it. Hover over a stage in the pipeline to read its explanation.

    Look for

    In the pipeline the send, write, flush and replay bars and, for the slowest stage, a label such as 'Bottleneck: replay'. In the chart the Write Lag, Flush Lag and Replay Lag lines, the 'WAL Behind' area (MB) and 'warn 1s' / 'crit 5s' lines; in the health card, where present, 'lag trend: worsening ↑' or 'improving ↓'.

    How to read it

    The pipeline shows each stage's own delay, taken as the worst value across the replicas; flush is computed by subtracting write and replay by subtracting flush, while send is approximated from the write lag. The largest stage is marked 'Bottleneck' when it is at least 0.05 s. The stage tips are the product's own text: a high Send means a network or sender bottleneck; a high Write means disk write throughput pressure on the replica; a high Flush means fsync / disk durability pressure; a high Replay means a single-process apply bottleneck, long-running queries or replay conflicts. In the chart a short spike that returns points to a passing load, while a line that keeps climbing over the hour is accumulating lag, and the 'lag trend' in the health card states that direction separately. The 'WAL Behind' area is the same lag in bytes. The 'warn 1s' / 'crit 5s' lines are drawn only when the values get close to that level. When replay dominates, typically look at the Queries tab on the standby node (long-running read queries can delay replay); treat that as DBA advice, not as a finding the screen reports.

  4. Step 4: Observe → Performance Analyzer → PostgreSQL → Replication

    Do

    Look at the 'Slots & WAL retention' card: the 'N retained' and 'N inactive' labels in its header, then the table (sorted by 'Retained').

    Look for

    In the table Slot, Type, Database, State (active / inactive), WAL status, Retained and Flush lag. In warning or critical state a recommendation box above the table. With no slots the text 'No replication slots'.

    How to read it

    A slot holds WAL: when empty the screen says 'Nothing is pinning WAL on this node'. An inactive slot keeps holding WAL because no consumer is connected; the health card writes this as '1 inactive slot retains X' and its level is critical when a slot is critical. 'Retained' is highlighted on an inactive slot. WAL status 'lost' is shown as critical and 'extended' and 'unreserved' in the warning colour. Typically for a slot that has been inactive for a long time the options are to reconnect the consumer or, if it is truly not needed, drop the slot; dropping is not done from ClusterEye and this is DBA advice. To see the same WAL build-up in terms of disk space and a forecast go to the next step.

  5. Step 5: Observe → Performance Analyzer → PostgreSQL → WAL Safety Center

    Do

    On the same node open the 'WAL Safety Center' tab and choose the time range.

    Look for

    In the header the role tag and, if it is off, a red 'archive_mode=off'. The 'pg_wal Growth + 2h Forecast' chart (solid line observed, dashed line linear projection, red line 'capacity'), the 'Replication Slots' card (Slot, Type, Active, Retained WAL) and 'DBA Findings & Recommendations'.

    How to read it

    The chart shows pg_wal growth and a two-hour linear projection together with the disk capacity line; if the dashed line heads for the red line, the accumulating WAL is heading towards filling the disk. The projection is linear, not a certainty. On a standby node the tab shows 'Standby node — archive analysis informational only', saying archive analysis is informational there while replication slot and pg_wal disk warnings still apply. The findings and recommendations sit under the tab's own heading; this guide does not walk through them one by one.

  6. Step 6: Observe → Performance Analyzer → PostgreSQL → Replication

    Do

    Go back to the Replication tab and read the 'Diagnosis' card; also look at the 'Configuration' card beside the health card.

    Look for

    In Diagnosis an 'N findings' counter and, per finding, a title, description, evidence and a category tag (Network, Disk / IO, WAL, Query, Replica node) with a replica tag where it applies; a 'Signals' list; numbered 'Recommendations' (with replica, 'tool' and 'conf' percentage tags). With no problem it says 'No active issues detected'. In Configuration synchronous_commit, synchronous_standby_names, max_wal_senders, hot_standby_feedback and wal_receiver_timeout.

    How to read it

    The category tag says which layer a finding belongs to; you can typically match it against the stage information from steps 2 and 3 (for example a Disk / IO finding with the Write or Flush stage). Each recommendation carries a confidence percentage; read a low-confidence one as a hint, not as evidence. The 'tool' tag shows the tool or command suggested alongside the recommendation; ClusterEye does not run it. The Configuration card only shows the reported values; you change a value on the server yourself. On a standalone node Diagnosis says 'Nothing to diagnose' and analysis starts only once a standby is connected.

    • If you see: The cluster is managed by Patroni and you also want to see failover readiness → Step 7
  7. Step 7: Observe → Performance Analyzer → PostgreSQL → Patroni Management

    Do

    Open the 'Patroni Management' tab (the page heading is 'Patroni Cluster Management') and stay on its 'Cluster Overview' tab.

    Look for

    At the top the Leader, Sync standby, Max replay lag, Failover candidates, DCS and Auto-failover tiles. Below them the 'Cluster health' card, 'Replication topology', 'Failover readiness', the 'Members' table (Member, Role, State, TL, LSN, a lag column, Tags, Attention, Actions) and 'Leader history'.

    How to read it

    The 'Max replay lag' tile shows the member furthest behind and the limit (maximum_lag_on_failover); the tip in the members table says members above that limit are not promoted. The 'Failover readiness' card gives the sentence 'If <leader> failed now, Patroni would promote <member>' and a checklist per member: is the REST API reachable, is there a nofailover tag, watchdog, is the lag within the limit, is the timeline the leader's, if synchronous_mode is on is the member synchronous, and is the state running/streaming. When a member is 'Not eligible' the reason shows as a red line in that list; 'Not verified' means some checks need a newer agent. When only one candidate is left the card warns about it separately. With no leader the tab shows a 'No leader' warning and, if auto-failover is paused, says Patroni will not elect a leader by itself. This step is reading only; Switchover, Failover, Pause and the member actions (Restart PostgreSQL, Reload Configuration, Reinitialize Replica) need Admin or DBA and are outside this guide.

Outcome

By the end you know on which replica, at which stage (send, write, flush or replay) and from which cause (transport, disk, replay pressure, an inactive slot) the lag is building up. The Replication and WAL Safety Center tabs only read; fixing the network, the disk, a long query or a slot is done on the server. On Patroni clusters the Actions menu in the Members table (Restart PostgreSQL, Reload Configuration, Reinitialize Replica, Force Reinitialize) and the Switchover/Failover buttons do run from ClusterEye; they need Admin or DBA and a Pro/Enterprise licence and are not steps this guide points you to. For thresholds and notifications see the 'Setting alarm thresholds and notification channels' guide.

Getting started
Setting alarm thresholds and notification channels

Set up the Slack, Email and Teams channels in Settings, route alarms to channels with Alert Routing, and decide in Thresholds when each alarm warns or turns critical.

Performance
A slow query in PostgreSQL: finding it and reading its plan and load

On the Queries tab of PostgreSQL Performance Analytics find the slow or heavy query with the modes and columns, read its impact breakdown, suggestions, execution plan and time trend in the drawer, and use AI Query Assist when needed.

Incident response
Alarm triage: finding, owning, snoozing and resolving an alarm

On the Alarms page prioritise active alarms, read an alarm's detail, acknowledge and own it, snooze it or silence it with a maintenance window when needed, and close it as resolved.

Incident response
What happened last night: reading incidents and root cause on the Timeline

On the Timeline page narrow the last 24 hours by severity, read an incident's root-cause summary and story, drill into raw events and, if needed, get a plain-language account with AI Explain.

Capacity
Capacity before the disk fills: which space, and how soon

On PostgreSQL and SQL Server read which disk and which database is filling from the Volumes, Capacity Planning and Storage screens, and on Oracle from the Tablespaces tab; learn how to read the growth rate and the 'days until full' estimate.