postgres-errors-replication-lag
Installation
SKILL.md
postgres-errors-replication-lag
Quick Reference :
Three replication problems, three different views to inspect :
| Problem | Where to look | Key signal |
|---|---|---|
| Streaming replica behind | pg_stat_replication (on PRIMARY) |
replay_lag, byte diff vs replay_lsn |
| Slot retaining too much WAL | pg_replication_slots (on PRIMARY) |
active = false, wal_status not reserved |
| Logical subscription behind / stuck | pg_stat_subscription (on SUBSCRIBER) |
stale latest_end_time, errors in subscriber log |
Two failures cause real outages :
- Inactive slot fills the primary disk. A replication slot pins WAL from
restart_lsnforward. If its consumer stops connecting,restart_lsnnever advances andpg_walgrows without bound until the primary crashes on a full disk. ALWAYS setmax_slot_wal_keep_sizeas a safety cap and ALWAYS alarm on inactive slots.