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
- Databases25% match
PostgreSQL replica stops streaming WAL after pg_repack on primary; replication slot reports missing WAL
Open0 answers - Databases23% match
WAL archiving stalls and primary reports 'could not flush file' during checkpoint under nightly bulk load
Open0 answers - Databases23% match
PostgreSQL primary WAL sender CPU spikes and replication lag after enabling frequent TLS renegotiation on streaming replication
Open0 answers - Databases21% match
PostgreSQL replica falls behind and reports WAL streaming delay when frequent autovacuum runs on primary
Open0 answers - Databases21% match
PostgreSQL logical replication falls behind after ALTER TABLE ADD COLUMN with non-null DEFAULT on large table
Open0 answers