Skip to content
pgautofailover

pgautofailover

pgautofailover : pg_auto_failover

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
5150
pgautofailover
pgautofailover
2.2
ADMIN
PostgreSQL
C
AttributeHas BinaryHas LibraryNeed LoadHas DDLRelocatableTrusted
--sLd--
No
Yes
Yes
Yes
no
no
Relationships
Requires
btree_gist
See Also
pglogical
pglogical_origin
pg_failover_slots
pgpool_recovery
repmgr
pg_checksums
pgpool_adm
bgw_replstatus

Packages

TypeRepoVersionPG Major CompatibilityPackage PatternDependencies
EXT
PGDG
2.2
18
17
16
15
14
pgautofailoverbtree_gist
RPM
PGDG
2.2
18
17
16
15
14
pg_auto_failover_$v-
DEB
PGDG
2.2
18
17
16
15
14
postgresql-$v-auto-failover-
Linux / PGPG18PG17PG16PG15PG14
el8.x86_64
MISS
PGDG 2.2
PGDG 2.2
PGDG 2.2
PGDG 2.2
el8.aarch64
MISS
PGDG 2.2
PGDG 2.2
PGDG 2.2
PGDG 2.2
el9.x86_64
MISS
PGDG 2.2
PGDG 2.2
PGDG 2.2
PGDG 2.2
el9.aarch64
MISS
PGDG 2.2
PGDG 2.2
PGDG 2.2
PGDG 2.2
el10.x86_64
MISS
PGDG 2.2
PGDG 2.2
PGDG 2.2
PGDG 2.2
el10.aarch64
MISS
PGDG 2.2
PGDG 2.2
PGDG 2.2
PGDG 2.2
d12.x86_64
PGDG 2.2
PGDG 2.2
PGDG 2.2
PGDG 2.2
PGDG 2.2
d12.aarch64
PGDG 2.2
PGDG 2.2
PGDG 2.2
PGDG 2.2
PGDG 2.2
d13.x86_64
PGDG 2.2
PGDG 2.2
PGDG 2.2
PGDG 2.2
PGDG 2.2
d13.aarch64
PGDG 2.2
PGDG 2.2
PGDG 2.2
PGDG 2.2
PGDG 2.2
u22.x86_64
PGDG 2.2
PGDG 2.2
PGDG 2.2
PGDG 2.2
PGDG 2.2
u22.aarch64
PGDG 2.2
PGDG 2.2
PGDG 2.2
PGDG 2.2
PGDG 2.2
u24.x86_64
PGDG 2.2
PGDG 2.2
PGDG 2.2
PGDG 2.2
PGDG 2.2
u24.aarch64
PGDG 2.2
PGDG 2.2
PGDG 2.2
PGDG 2.2
PGDG 2.2
u26.x86_64
PGDG 2.2
PGDG 2.2
PGDG 2.2
PGDG 2.2
PGDG 2.2
u26.aarch64
PGDG 2.2
PGDG 2.2
PGDG 2.2
PGDG 2.2
PGDG 2.2
PackageVersionOSORGSIZEFile URL
postgresql-18-auto-failover2.2d12.x86_64pgdg377.7 KiBpostgresql-18-auto-failover_2.2-3.pgdg12+1_amd64.deb
postgresql-18-auto-failover2.2d12.aarch64pgdg373.6 KiBpostgresql-18-auto-failover_2.2-3.pgdg12+1_arm64.deb
postgresql-18-auto-failover2.2d13.x86_64pgdg379.1 KiBpostgresql-18-auto-failover_2.2-3.pgdg13+1_amd64.deb
postgresql-18-auto-failover2.2d13.aarch64pgdg374.8 KiBpostgresql-18-auto-failover_2.2-3.pgdg13+1_arm64.deb
postgresql-18-auto-failover2.2u22.x86_64pgdg378.3 KiBpostgresql-18-auto-failover_2.2-3.pgdg22.04+1_amd64.deb
postgresql-18-auto-failover2.2u22.aarch64pgdg374.1 KiBpostgresql-18-auto-failover_2.2-3.pgdg22.04+1_arm64.deb
postgresql-18-auto-failover2.2u24.x86_64pgdg369.2 KiBpostgresql-18-auto-failover_2.2-3.pgdg24.04+1_amd64.deb
postgresql-18-auto-failover2.2u24.aarch64pgdg364.7 KiBpostgresql-18-auto-failover_2.2-3.pgdg24.04+1_arm64.deb
postgresql-18-auto-failover2.2u26.x86_64pgdg368.7 KiBpostgresql-18-auto-failover_2.2-3.pgdg26.04+1_amd64.deb
postgresql-18-auto-failover2.2u26.aarch64pgdg364.4 KiBpostgresql-18-auto-failover_2.2-3.pgdg26.04+1_arm64.deb

Source

Install

Make sure PGDG repo available:

pig repo add pgdg -u    # add pgdg repo and update cache

Install this extension with pig:

pig install pgautofailover;		# install via package name, for the active PG version

pig install pgautofailover -v 18;   # install for PG 18
pig install pgautofailover -v 17;   # install for PG 17
pig install pgautofailover -v 16;   # install for PG 16
pig install pgautofailover -v 15;   # install for PG 15
pig install pgautofailover -v 14;   # install for PG 14

Config this extension to shared_preload_libraries:

shared_preload_libraries = 'pgautofailover';

Create this extension with:

CREATE EXTENSION pgautofailover CASCADE; -- requires btree_gist

Usage

pgautofailover: pg_auto_failover

pg_auto_failover is an extension and service for automated PostgreSQL failover. It consists of a monitor node (running the pgautofailover extension), and keeper processes on each data node managed by the pg_autoctl CLI.

Architecture

  • Monitor: a PostgreSQL instance with the pgautofailover extension that implements a state machine for failover decisions
  • Keeper (pg_autoctl run): runs on each data node, reports health to the monitor and executes state transitions
  • Supports 2+ node setups with synchronous replication by default
  • Supports Citus HA (since v2.0)

Key CLI Commands

# Create the monitor
pg_autoctl create monitor --pgdata /path/to/monitor --pgport 5000

# Create a data node (primary or secondary auto-assigned)
pg_autoctl create postgres --pgdata /path/to/data --pgport 5001 --monitor postgres://monitor:5000/pg_auto_failover

# Run the keeper (foreground)
pg_autoctl run --pgdata /path/to/data

# Check cluster state
pg_autoctl show state --pgdata /path/to/monitor

# Perform a manual switchover
pg_autoctl perform switchover --pgdata /path/to/monitor

# Perform a manual failover
pg_autoctl perform failover --pgdata /path/to/monitor

Failover Behavior

The monitor tracks node health. When a secondary becomes unavailable or its lag is too high, it is removed from synchronous_standby_names on the primary. Failover/switchover operations are blocked until the secondary is healthy again, preventing data loss.

Documentation

Full documentation: pg-auto-failover.readthedocs.io

Last updated on