What is this issue?
PostgreSQL replication slots ensure a replica can catch up even if temporarily
disconnected by retaining all WAL files since the slot was last consumed.
An inactive slot (no consumer connected) is dangerous because:
- WAL files accumulate indefinitely
- Disk can fill up, causing a database crash
- Dead tuples can't be vacuumed (if slot has old xmin)
Common causes:
- Replica server is down or unreachable
- Logical replication subscriber was deleted but slot remains
- CDC tool (Debezium, etc.) stopped without cleanup
Why it matters
Disk Space
WAL files grow without bound until disk is full
Database Crash
Running out of disk space can crash PostgreSQL
Vacuum Blocking
Old slot xmin prevents dead tuple cleanup
Performance
Many WAL files slow down directory operations
How PG Pilot detects it
```sql
SELECT
slot_name,
slot_type,
database,
active,
restart_lsn,
pg_size_pretty(
pg_current_wal_lsn() - restart_lsn
) AS retained_wal
FROM pg_replication_slots
WHERE NOT active;
```
How to fix it
Identify the slot's purpose
Check what created this slot:
SELECT slot_name, slot_type, plugin, database
FROM pg_replication_slots
WHERE slot_name = 'your_slot_name';- physical type: Streaming replication
- logical type: Logical replication or CDC tool
Verify the consumer is gone
Ensure the consumer (replica/CDC tool) is intentionally stopped
and won't be restarted.
For physical replication, check if the standby server is running.
For logical replication, check the subscription status.
Drop the slot
If the slot is no longer needed:
SELECT pg_drop_replication_slot('your_slot_name');This immediately releases all retained WAL files.
Monitor disk recovery
After dropping, verify disk space is reclaimed:
SELECT pg_size_pretty(sum(size)) AS wal_size
FROM pg_ls_waldir();Prevention
- Always clean up slots when decommissioning replicas
- Monitor slot activity with PG Pilot
- Set up alerts for inactive slots
- Document all replication slots and their purposes