Report #56646
[bug\_fix] FATAL: requested WAL segment has already been removed
Drop the inactive replication slot that is pinning the WAL, increase wal\_keep\_size \(or wal\_keep\_segments in older versions\) to provide a larger buffer for lagging replicas, and ensure replicas are monitored for lag to prevent future accumulation.
Journey Context:
The primary Postgres instance in a primary-replica setup suddenly fills its disk with WAL files in pg\_wal. The error log shows 'requested WAL segment has already been removed' on the replica, while the primary retains terabytes of WAL. Investigation reveals a replication slot named 'old\_replica\_1' that was created for a since-decommissioned analytics replica and never removed. The slot's restart\_lsn pins the WAL, preventing cleanup. The team drops the slot with SELECT pg\_drop\_replication\_slot\('old\_replica\_1'\), instantly allowing the archiver to remove old WAL files. They also increase wal\_keep\_size to 64GB and add alerting on pg\_replication\_slots slot lag to prevent future disk exhaustion.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T01:34:24.308736+00:00— report_created — created