Why pgraft
Automatic Leader Election
Quorum-based, deterministic, fully automated leader election using proven etcd-io/raft implementation.
Crash-Safe Replication
All state changes replicated and persisted across nodes. Survives crashes and network partitions.
100% Split-Brain Prevention
Mathematical guarantee via Raft consensus protocol—never more than one leader per term.
Zero-Downtime Failover
Sub-second detection and automatic recovery. Seamless failover with no service interruption.
Production-Grade Raft
Built on proven etcd-io/raft library used in production by etcd, Kubernetes, and other systems.
Native PostgreSQL Integration
Background worker architecture with no external dependencies. Pure PostgreSQL extension.
Comprehensive SQL API
Full cluster management via SQL functions. Monitor, manage, and control through standard SQL.
Built-in Observability
Status functions, metrics, detailed logging, and monitoring hooks for complete cluster visibility.
etcd-Compatible KV Store
Raft-replicated key-value storage included. Perfect for distributed configuration and coordination.
| Capability | Description | Operational Impact | Performance | Scalability |
|---|---|---|---|---|
| Consensus (Raft) | Leader election, log replication, term monotonicity. | Deterministic failover; no split-brain. | Sub-second leader election | 3-5 nodes optimal |
| State Durability | Persistent HardState, entries, snapshots. | Crash-safe recovery. | WAL-based persistence | Unlimited log entries |
| Command Interface | SQL functions for init, membership, diagnostics. | Native DB admin UX. | Zero-latency SQL access | Per-connection scaling |
| Monitoring Hooks | Cluster status, log stats, leader checks. | Simplifies observability. | Real-time metrics | Multi-cluster support |
| Node Membership | Add/remove nodes through leader replication. | Controlled scaling. | Online reconfiguration | Dynamic cluster size |
| Debug Mode | Toggle extended logging via SQL. | Faster incident analysis. | Configurable verbosity | Per-node granularity |
| Feature | pgraft | Patroni | Stolon | RepMgr |
|---|---|---|---|---|
| Consensus Protocol | Raft (libraft) | etcd/Consul | etcd | None |
| PostgreSQL Integration | Native Extension | External Agent | External Agent | External Agent |
| Split-Brain Prevention | ✔️ | ✔️ | ✔️ | ✗ |
| SQL Interface | ✔️ | ✗ | ✗ | ✗ |
| Zero External Dependencies | ✔️ | ✗ | ✗ | ✔️ |
| Background Workers | ✔️ | ✗ | ✗ | ✗ |
Deploy Raft Consensus for PostgreSQL
Install pgraft and enable automatic leader election, crash-safe replication, and 100% split-brain prevention for your PostgreSQL clusters.