Locate the delayed replication stage
Replication lag is the delay between a change on a primary and its availability at a replica or other replication target. Split the pipeline into sending, receiving, durable writing and replay rather than treating the path as one opaque queue. A successful primary commit does not establish that an asynchronous reader has already applied the change. An application symptom such as an order disappearing immediately after creation must therefore be investigated together with routing and the consistency guarantee the application actually needs.
A committed write is not yet visible on a replica
For example, a client creates an order on the primary and immediately sends a lookup through a read replica. If replay has not reached the change’s WAL position, the order may be absent from that replica’s snapshot. This is an explainable asynchronous behavior, but not necessarily an acceptable product behavior. Reading from the primary after a write or waiting for an appropriate replication condition can support a read-your-writes requirement. A fixed sleep is not a guarantee that the replica will catch up under every load and failure scenario.
Use byte gaps and time gaps carefully
In PostgreSQL, fields such as sent_lsn, write_lsn, flush_lsn and replay_lsn in pg_stat_replication help separate pipeline stages. Differences in WAL positions measure a byte gap, not an automatic estimate of seconds remaining. Converting backlog into time requires a meaningful processing rate. Time-lag fields also require interpretation when the primary is idle or no recent changes exist. If receipt advances while replay does not, investigate replay work, storage behavior and interactions with reader queries rather than assuming the network link is the only possible bottleneck.
Check retention as well as replay capacity
Choose a response based on the constrained stage. Settings that reduce conflicts between standby readers and replay can change query cancellation behavior or retain more old row versions on the primary. Replication slots may retain required WAL, so delayed consumption can also become a primary disk-capacity problem. Monitor retained bytes and recovery options alongside reader freshness. Switching to synchronous replication or promoting a standby changes availability and durability assumptions; neither is a casual reaction to one lag number. Verify that the chosen intervention improves freshness without violating the service’s failure and recovery requirements.