pg_replica
pg_replica · Consensus-driven automatic failover for PostgreSQL
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 101606 | pg_replica | pg_replica | 0.7.7 | ADMIN | AGPL-3.0-only | Rust |
PostgreSQL · 18
Usage
Sources:
pg_replica 0.7.7 adds embedded Raft leadership and failover to physical PostgreSQL replication. It targets PostgreSQL 18 and requires a configured cluster, preload and restart; extension creation alone does not establish replication.
Core Workflow
Operational Boundaries
replica.status() reports leadership and replication state. replica.rotate_credential() changes a credential on the current primary and is a no-op on standbys. A supervisor still manages process restarts, and clients need reconnect/routing logic. Quorum-synchronous durability is opt-in; do not describe asynchronous operation as lossless. Rejoining can use rewind or a complete base backup, and adopting a restored primary can discard data from the former primary. Review node membership, credentials, fencing and recovery procedures before enabling the background workers. Installation requires a superuser.
The supervisor idles until node identity, peer membership and a durable Raft directory are configured. Keep consensus membership and physical replication recovery consistent. Version 0.7.7 documents rewind of a standby on a diverged timeline; failed or inapplicable rewind can still require a complete base backup. The synchronous-quorum mode is a restart-time choice. Do not promote a recovered node with adopt-primary tooling without fencing the former writer and accepting the documented replacement of its history.