pg_failover_slots

PG Failover Slots extension

Overview

PackageVersionCategoryLicenseLanguage
pg_failover_slots1.2.0ETLPostgreSQLC
IDExtensionBinLibLoadCreateTrustRelocSchema
9530pg_failover_slotsNoYesYesNoNoYes-
Relatedpglogical pglogical_origin pglogical_ticker pgactive repmgr bgw_replstatus pgl_ddl_deploy decoderbufs

Version

TypeRepoVersionPG VerPackageDeps
EXTPIGSTY1.2.01817161514pg_failover_slots-
RPMPIGSTY1.2.01817161514pg_failover_slots_$v-
DEBPIGSTY1.2.01817161514postgresql-$v-pg-failover-slots-
OS / PGPG18PG17PG16PG15PG14
el8.x86_64
el8.aarch64
el9.x86_64
el9.aarch64
el10.x86_64
el10.aarch64
d12.x86_64
PGDG 1.2.0
d12.aarch64
PGDG 1.2.0
d13.x86_64
PGDG 1.2.0
PGDG 1.2.0
PGDG 1.2.0
PGDG 1.2.0
PGDG 1.2.0
d13.aarch64
PGDG 1.2.0
PGDG 1.2.0
PGDG 1.2.0
PGDG 1.2.0
PGDG 1.2.0
u22.x86_64
PGDG 1.2.0
u22.aarch64
PGDG 1.2.0
u24.x86_64
PGDG 1.2.0
u24.aarch64
PGDG 1.2.0

Build

You can build the RPM / DEB packages for pg_failover_slots using pig build:

pig build pkg pg_failover_slots         # build RPM / DEB packages

Install

You can install pg_failover_slots directly. First, make sure the PGDG and PIGSTY repositories are added and enabled:

pig repo add pgsql -u          # Add repo and update cache

Install the extension using pig or apt/yum/dnf:

pig install pg_failover_slots;          # Install for current active PG version
pig ext install -y pg_failover_slots -v 18  # PG 18
pig ext install -y pg_failover_slots -v 17  # PG 17
pig ext install -y pg_failover_slots -v 16  # PG 16
pig ext install -y pg_failover_slots -v 15  # PG 15
pig ext install -y pg_failover_slots -v 14  # PG 14
dnf install -y pg_failover_slots_18       # PG 18
dnf install -y pg_failover_slots_17       # PG 17
dnf install -y pg_failover_slots_16       # PG 16
dnf install -y pg_failover_slots_15       # PG 15
dnf install -y pg_failover_slots_14       # PG 14
apt install -y postgresql-18-pg-failover-slots   # PG 18
apt install -y postgresql-17-pg-failover-slots   # PG 17
apt install -y postgresql-16-pg-failover-slots   # PG 16
apt install -y postgresql-15-pg-failover-slots   # PG 15
apt install -y postgresql-14-pg-failover-slots   # PG 14

Preload:

shared_preload_libraries = 'pg_failover_slots';

Usage

pg_failover_slots: PG Failover Slots extension

Makes logical replication slots usable across a physical failover by synchronizing slot state from primary to standby.

Enabling

Add to postgresql.conf on both primary and standby:

shared_preload_libraries = 'pg_failover_slots'

Required settings on standby:

hot_standby_feedback = on
primary_slot_name = 'my_physical_slot'  -- must be non-empty

Configuration Options

# Which slots to synchronize (default: all logical slots)
pg_failover_slots.synchronize_slot_names = 'name_like:%'

# Synchronize specific slots
pg_failover_slots.synchronize_slot_names = 'my_slot,plugin:test_decoding'

# Drop extra slots on standby not found on primary (default: true)
pg_failover_slots.drop_extra_slots = true

# Connection string to primary (default: uses primary_conninfo)
pg_failover_slots.primary_dsn = 'host=primary dbname=mydb'

# Ensure physical standbys receive data before logical consumers
pg_failover_slots.standby_slot_names = 'standby_physical_slot'

# How many standby slots must confirm (default: -1 = all)
pg_failover_slots.standby_slots_min_confirmed = -1

# Sync interval in ms (default: 60000)
pg_failover_slots.worker_nap_time = 60000

Checking Standby Readiness

Verify all logical slots are synchronized before failover:

-- On standby: all slots should show active = false
SELECT slot_name, active FROM pg_replication_slots WHERE slot_type = 'logical';

--  slot_name        | active
-- ------------------+--------
--  regression_slot1 | f        -- synchronized, ready
--  regression_slot2 | f        -- synchronized, ready
--  regression_slot3 | t        -- still syncing, NOT ready

When all slots show active = false, the standby is safe for failover.

Key Behaviors

  • Copies missing replication slots from primary to standby
  • Removes extra slots on standby not found on primary
  • Periodically synchronizes slot positions
  • standby_slot_names provides a synchronous replication barrier to prevent data loss on failover
  • Requires PostgreSQL 11 or higher

Last Modified 2026-03-12: add pg extension catalog (95749bf)