Create and drop a replication slot
PostgreSQLReplicationCommand
SELECT pg_create_physical_replication_slot('replica_slot_1'); -- To drop: SELECT pg_drop_replication_slot('replica_slot_1');What it does
Creates a physical slot that guarantees the primary does not remove required WAL until the standby confirms it; the second command removes the slot.
When to use it
To ensure the standby does not lose WAL during short outages.
Caution
An unused/abandoned slot leads to WAL accumulation and a full disk. Monitor slot status: SELECT slot_name, active, pg_size_pretty(pg_wal_lsn_diff(pg_current_wal_lsn(), restart_lsn)) AS retained FROM pg_replication_slots; An active slot cannot be dropped.