Specify the maximum size of WAL files that replication slots are allowed to retain in the pg_wal directory at checkpoint time.
At a glance
| Property | Value |
|---|---|
| Parameter | max_slot_wal_keep_size |
| Category | Replication |
| Default | -1 |
| Value type | integer |
| Change scope | Reload (postgresql.conf, SIGHUP) |
| Available in | PostgreSQL 13, 14, 15, 16, 17, 18, 19 (added in 13) |
What it does
Specify the maximum size of WAL files that replication slots are allowed to retain in the pg_wal directory at checkpoint time. If max_slot_wal_keep_size is -1 (the default), replication slots may retain an unlimited amount of WAL files. Otherwise, if restart_lsn of a replication slot falls behind the current LSN by more than the given size, the standby using the slot may no longer be able to continue replication due to removal of required WAL files. You can see the WAL availability of replication slots in pg_replication_slots. If this value is specified without units, it is taken as megabytes. This parameter can only be set in the postgresql.conf file or on the server command line.
(Description quoted from the official PostgreSQL documentation.)
How to apply a change
Set it in postgresql.conf (or with ALTER SYSTEM) and reload with SELECT pg_reload_conf(); or pg_ctl reload — no restart needed.
Inspect the current value and source with SHOW max_slot_wal_keep_size; or SELECT name, setting, unit, context, source FROM pg_settings WHERE name = 'max_slot_wal_keep_size';.
Tuning guidance
Cap how much WAL a replication slot may pin so a dead/slow consumer cannot fill the disk; once exceeded the slot is invalidated. Size it to your largest tolerable replica lag in WAL bytes.