replication slot
also: WAL retention, replication stream tracking
A PostgreSQL mechanism that tracks the position of a logical or physical replication stream, ensuring a primary database retains WAL (Write-Ahead Log) files needed by a standby or subscriber until they have consumed the data.
A replication slot is a PostgreSQL feature that manages the consumption of changes from a primary database by replicas or logical subscribers. It maintains a pointer to the current position in the WAL stream, preventing the primary from discarding log segments that a replica hasn't yet read.
Without replication slots, a primary might delete WAL files before a slow replica had a chance to read them, causing replication to fail. Slots solve this by telling the primary: "keep WAL around until subscriber X confirms they've received up to this point."
There are two types: physical replication slots (for streaming replicas) and logical replication slots (for extracting logical changes to external systems). For example, a logical slot might decode changes to JSON and send them to a message queue.
SELECT * FROM pg_replication_slots; shows active slots. Unused slots can waste disk space, so they should be dropped when no longer needed.