pg_failover_slots
pg_failover_slots
pg_failover_slots : PG Failover Slots extension
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 9530 | pg_failover_slots
|
pg_failover_slots
|
1.2.0 |
ETL
|
PostgreSQL
|
C
|
| Attribute | Has Binary | Has Library | Need Load | Has DDL | Relocatable | Trusted |
|---|---|---|---|---|---|---|
--sL--r
|
No
|
Yes
|
Yes
|
No
|
yes
|
no
|
| Relationships | |
|---|---|
| See Also | pglogical
pglogical_origin
pglogical_ticker
pgactive
repmgr
bgw_replstatus
pgl_ddl_deploy
decoderbufs
|
Packages
| Type | Repo | Version | PG Major Compatibility | Package Pattern | Dependencies |
|---|---|---|---|---|---|
| EXT | PIGSTY
|
1.2.0 |
18
17
16
15
14
|
pg_failover_slots |
- |
| RPM | PIGSTY
|
1.2.0 |
18
17
16
15
14
|
pg_failover_slots_$v |
- |
| DEB | PIGSTY
|
1.2.0 |
18
17
16
15
14
|
postgresql-$v-pg-failover-slots |
- |
| Linux / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
el8.x86_64
|
PIGSTY 1.2.0
|
PIGSTY 1.2.0
|
PIGSTY 1.2.0
|
PIGSTY 1.2.0
|
PIGSTY 1.2.0
|
el8.aarch64
|
PIGSTY 1.2.0
|
PIGSTY 1.2.0
|
PIGSTY 1.2.0
|
PIGSTY 1.2.0
|
PIGSTY 1.2.0
|
el9.x86_64
|
PIGSTY 1.2.0
|
PIGSTY 1.2.0
|
PIGSTY 1.2.0
|
PIGSTY 1.2.0
|
PIGSTY 1.2.0
|
el9.aarch64
|
PIGSTY 1.2.0
|
PIGSTY 1.2.0
|
PIGSTY 1.2.0
|
PIGSTY 1.2.0
|
PIGSTY 1.2.0
|
el10.x86_64
|
PIGSTY 1.2.0
|
PIGSTY 1.2.0
|
PIGSTY 1.2.0
|
PIGSTY 1.2.0
|
PIGSTY 1.2.0
|
el10.aarch64
|
PIGSTY 1.2.0
|
PIGSTY 1.2.0
|
PIGSTY 1.2.0
|
PIGSTY 1.2.0
|
PIGSTY 1.2.0
|
d12.x86_64
|
PGDG 1.2.0
|
PGDG 1.2.0
|
PGDG 1.2.0
|
PGDG 1.2.0
|
PGDG 1.2.0
|
d12.aarch64
|
PGDG 1.2.0
|
PGDG 1.2.0
|
PGDG 1.2.0
|
PGDG 1.2.0
|
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
|
PGDG 1.2.0
|
PGDG 1.2.0
|
PGDG 1.2.0
|
PGDG 1.2.0
|
u22.aarch64
|
PGDG 1.2.0
|
PGDG 1.2.0
|
PGDG 1.2.0
|
PGDG 1.2.0
|
PGDG 1.2.0
|
u24.x86_64
|
PGDG 1.2.0
|
PGDG 1.2.0
|
PGDG 1.2.0
|
PGDG 1.2.0
|
PGDG 1.2.0
|
u24.aarch64
|
PGDG 1.2.0
|
PGDG 1.2.0
|
PGDG 1.2.0
|
PGDG 1.2.0
|
PGDG 1.2.0
|
Source
pig build pkg pg_failover_slots; # build rpm/debInstall
Make sure PGDG and PIGSTY repo available:
pig repo add pgsql -u # add both repo and update cacheInstall this extension with pig:
pig install pg_failover_slots; # install via package name, for the active PG version
pig install pg_failover_slots -v 18; # install for PG 18
pig install pg_failover_slots -v 17; # install for PG 17
pig install pg_failover_slots -v 16; # install for PG 16
pig install pg_failover_slots -v 15; # install for PG 15
pig install pg_failover_slots -v 14; # install for PG 14Config this extension to shared_preload_libraries:
shared_preload_libraries = 'pg_failover_slots';This extension does not need CREATE EXTENSION DDL command
Usage
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-emptyConfiguration 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 = 60000Checking 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 readyWhen 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_namesprovides a synchronous replication barrier to prevent data loss on failover- Requires PostgreSQL 11 or higher
Last updated on