PostgreSQL logical replication slot grows until disk full after subscriber disconnects during nightly load
Environment
PostgreSQL 13.8 on Debian 11 VM (8 vCPU, 32 GB RAM), primary and one logical replica on separate hosts; publisher uses pglogical extension for cross-datacenter replication; WAL archived to local filesystem; nightly bulk import job (COPY) runs 02:00–03:00.
Symptoms
Primary host runs out of disk space on /var/lib/postgresql/13/main/WAL disk within 24 hours of a subscriber network blip; application errors 'could not write to file' and new transactions fail with 'no space left on device'.
Observations
pg_replication_slots shows a slot with confirmed_flush_lsn stagnating several GB behind current WAL; pg_stat_wal_receiver on subscriber shows 'disconnected' during the incident window; archive_command continued to write WAL files; df -h shows WAL/pg_wal partition at 100%; backup logs show base backup completed prior to incident; no long-running transactions on primary according to pg_stat_activity snapshot gathered after space freed.
Already attempted
Stopped the subscriber service and manually removed old WAL files (mv to tmp on separate disk) to restore space; restarted primary Postgres to resume normal operations; verified pg_replication_slots output; attempted to drop unused logical slot with pg_drop_replication_slot but slot is active and drop failed until subscriber was cleanly stopped.
Question
What is causing the logical replication slot to retain WAL (growing until disk full) after the subscriber disconnects during the nightly load, and what safe steps can I take to recover without data loss and prevent recurrence?
Verified community troubleshooting
No answers yet..
Incident analysis
Most likely causes
Summary
Suggested Fixes
Continue troubleshooting
Related troubles
Matched from the title, description and tags
- Databases41% match
Logical replication slot retains WAL and fills disk after subscriber disconnect during nightly bulk import
Open1 answer - Databases33% match
PostgreSQL logical replication slot grows and WAL accumulates after logical decoding plugin crashes on high-write primary
Open1 answer - Databases30% match
PostgreSQL standby stops applying WAL after pg_basebackup restore — replication slot grows and disk fills
Open0 answers - Databases25% match
PostgreSQL replica stops streaming WAL after pg_repack on primary; replication slot reports missing WAL
Open0 answers - Databases24% match
PostgreSQL WAL backlog and standby lag after nightly bulk UPDATE with synchronous rsync archive_command
Open0 answers