Parameter · Replication / Sending Servers
max_slot_wal_keep_size
Sets the maximum WAL size that can be reserved by replication slots. Replication slots will be marked as failed, and segments released for deletion or recycling, if this much space is occupied by WAL on disk. -1 means no maximum.
- Default:
-1 - Type: integer (MB)
- Range: -1 … max (2147483647)
- Applies: Reload
In plain words
Replication slots make the primary keep WAL until the consumer has read it. If a standby or subscriber disappears, that WAL piles up until the disk is full and the primary stops. max_slot_wal_keep_size puts a ceiling on it: when a slot would hold more than this, PostgreSQL gives up on that slot and frees the WAL.
The default -1 means no ceiling. Setting one protects the primary at the cost of having to rebuild a lagging consumer.
For DBAs and operators
Enforced at each checkpoint: any slot whose restart_lsn is more than this far behind the current WAL position is invalidated, and its WAL becomes removable.
LOG: invalidating obsolete replication slot "standby1"
DETAIL: The slot's restart_lsn 0/5A000060 exceeds the limit by 16777216 bytes.
After that the slot shows wal_status = 'lost' and (since PostgreSQL 17) invalidation_reason = 'wal_removed'. A physical standby then needs WAL from the archive or a re-clone; a logical subscription must be re-created and resynchronized.
SELECT slot_name, active, wal_status,
pg_size_pretty(safe_wal_size) AS until_invalidated
FROM pg_replication_slots;wal_status goes reserved → extended (beyond max_wal_size, still kept) → unreserved (will be removed at next checkpoint) → lost. Alert on safe_wal_size long before it reaches zero.
Pick a value that fits comfortably on the WAL volume together with max_wal_size and wal_keep_size. It is the most important safety net against an abandoned slot filling the disk.
How to change it
Change in postgresql.conf or ALTER SYSTEM, then run SELECT pg_reload_conf().
See it in context
Replication slots Streaming replication Checkpoints WAL sender Write-ahead log (WAL)
Related parameters
max_replication_slots wal_keep_size idle_replication_slot_timeout max_wal_size