pgbully
pgbully · Bully-algorithm leader election among PostgreSQL nodes
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 101971 | pgbully | pgbully | 1.0 | ADMIN | PostgreSQL | C |
PostgreSQL · 15, 16, 17, 18
Usage
Sources:
pgbully elects the highest reachable node ID as leader using the Bully algorithm. It coordinates independent PostgreSQL nodes; it does not replicate application tables or implement failover and fencing.
Configure the Cluster
On every PostgreSQL 15–18 node, configure a unique node ID and an identical peer list, with working libpq authentication between nodes. Append the library to the preload list and restart. Example for node 1:
SQL Workflow
Failure Boundaries
Installation requires a superuser. Status and membership objects live in the pgbully schema. pgbully.kv_put is leader-only and pgbully.kv_get reads local state; the optional store is best-effort rather than quorum-durable.
A network partition can elect one leader in each partition. Applications requiring a globally unique writer must provide an independent quorum/fencing mechanism; a successful leader check is not sufficient authorization to promote a database or perform an irreversible external action.