Lesson 13 of 14

Failover Slots: Keeping Logical Replication Alive Across a Failover (PostgreSQL 17)

Applies to PostgreSQL 13–17 Last reviewed Jun 2026 Grounded in source

The one thing to understand first

A replication slot is the bookmark that tells the primary how far a consumer has read and therefore which WAL it must keep. The catch that bit teams for years: slots existed only on the primary. Promote a standby and every logical replication slot vanished with the old primary — so every logical subscriber or change-data-capture consumer lost its position and had to be re-seeded, risking gaps or duplicates. PostgreSQL 17 fixes this with failover slots: a logical slot can be marked to survive failover, and the standby keeps a synchronized copy so the new primary already has the bookmark at a safe position.

This extends Pathway 04’s replication-slots and automatic-failover lessons by closing the gap they leave open: what happens to logical slots when the primary role actually moves.

The mechanism: marking a slot to survive

You opt a logical slot into failover when you create it — pg_create_logical_replication_slot(..., failover := true), or CREATE SUBSCRIPTION ... WITH (failover = true). That sets the failover flag you can see in pg_replication_slots. On its own that flag does nothing; it’s a declaration that this slot is important enough to be mirrored onto the failover-target standby.

This is a Pro lesson

Get every Learning Pathway and cookbook recipe — grounded in PostgreSQL source code, with diagnostics, fixes, and prevention for each topic.

Continue this lesson to learn:

  • The mechanism: the slot sync worker
  • The mechanism: don’t let the subscriber overtake the standby
  • Layer 3 — Prove the slot survives
  • Layer 4 — The levers this hands you
  • Layer 5 — What an Oracle DBA should expect vs what they get
  • Key takeaway
  • All 36 Learning Pathway lessons
  • 170+ cookbook recipes
  • Source-grounded diagnostics & fixes

Secure checkout Cancel anytime Source-grounded

Was this helpful?

← Back to 04 — Advanced: Replication & HA Architecture