Replication Slots: Guaranteeing WAL Retention
A standby reads the primary's change-log to stay current.
If the primary deletes part of that log before the standby has read it, the standby is stranded and must be rebuilt from scratch. A replication slot is a bookmark that tells the primary exactly how far each standby has gotten, so it never throws away a log they still need.
Pro members see the rest of this lesson
- A 4-step state diagram: Healthy → Disconnect → Retain → Bound
- The full mechanism: what PostgreSQL does internally, in source terms
- 1 SQL query you can run, each labelled by how it was verified
- The closing insight, the mistake it prevents, and what it changes in your work
Card required. Cancel before day 7 and you are not charged.
Check it against the source1 citation in postgres/postgres · file, symbol and line verified on REL_17_STABLE
Primary symbol: ReplicationSlotCreate · line 338
Anchored to postgres/postgres on REL_17_STABLE and cross-checked against the manual for PostgreSQL 15–18. Every query here was run and its output captured on a throwaway PostgreSQL 17.10 lab; corrections are noted inline. §27.2.6 Replication Slots in the official docs →
Connected
Where this lesson sits
What comes before, after, and alongside it.
Part of these pathways
Same learning track
Finished a free lesson?
Pro opens the rest of the engine course
You felt one mechanism. Pro is the full bodies, interview depth, and the tracks that build on this session.