Skip to content
pgautofailover

pgautofailover

pgautofailover : pg_auto_failover

Overview

ID Extension Package Version Category License Language
5150
pgautofailover
pgautofailover
2.2
ADMIN
PostgreSQL
C
Attribute Has Binary Has Library Need Load Has DDL Relocatable Trusted
--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

Type Repo Version PG Major Compatibility Package Pattern Dependencies
EXT
PGDG
2.2
18
17
16
15
14
pgautofailover btree_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 / PG PG18 PG17 PG16 PG15 PG14
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
Package Version OS ORG SIZE File URL
postgresql-18-auto-failover 2.2 d12.x86_64 pgdg 377.7 KiB postgresql-18-auto-failover_2.2-3.pgdg12+1_amd64.deb
postgresql-18-auto-failover 2.2 d12.aarch64 pgdg 373.6 KiB postgresql-18-auto-failover_2.2-3.pgdg12+1_arm64.deb
postgresql-18-auto-failover 2.2 d13.x86_64 pgdg 379.1 KiB postgresql-18-auto-failover_2.2-3.pgdg13+1_amd64.deb
postgresql-18-auto-failover 2.2 d13.aarch64 pgdg 374.8 KiB postgresql-18-auto-failover_2.2-3.pgdg13+1_arm64.deb
postgresql-18-auto-failover 2.2 u22.x86_64 pgdg 378.3 KiB postgresql-18-auto-failover_2.2-3.pgdg22.04+1_amd64.deb
postgresql-18-auto-failover 2.2 u22.aarch64 pgdg 374.1 KiB postgresql-18-auto-failover_2.2-3.pgdg22.04+1_arm64.deb
postgresql-18-auto-failover 2.2 u24.x86_64 pgdg 369.2 KiB postgresql-18-auto-failover_2.2-3.pgdg24.04+1_amd64.deb
postgresql-18-auto-failover 2.2 u24.aarch64 pgdg 364.7 KiB postgresql-18-auto-failover_2.2-3.pgdg24.04+1_arm64.deb
postgresql-18-auto-failover 2.2 u26.x86_64 pgdg 368.7 KiB postgresql-18-auto-failover_2.2-3.pgdg26.04+1_amd64.deb
postgresql-18-auto-failover 2.2 u26.aarch64 pgdg 364.4 KiB postgresql-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