pg_paxos
pg_paxos · Paxos distributed consensus functions and table replication for PostgreSQL
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 100010 | pg_paxos | pg_paxos | 0.2 | ETL | PostgreSQL | C |
Usage
Sources:
pg_paxos is an abandoned, experimental implementation of Multi-Paxos table replication for PostgreSQL 9.4–9.6-era servers. It logs SQL text and re-executes it on group members; use it only for historical study or isolated experiments, not as a supported high-availability or production replication system.
Setup and Core Workflow
Install the declared dblink dependency on every node, preload pg_paxos, assign a unique node ID, and restart PostgreSQL:
On a new node with the same table definition and extensions, join the group with both the existing node’s and the new node’s connection strings:
If another table is added after group formation, call paxos_replicate_table(text, regclass) on every node as directed by upstream.
Configuration and Consistency
pg_paxos.node_idmust uniquely identify a node.pg_paxos.enabledenables interception for managed tables.pg_paxos.consistency_modelisstrongby default;optimisticreduces read coordination but can return stale data after failures.pg_paxos.allow_mutable_functionsdefaults to off because nondeterministic functions can make replicas diverge.
The planner and executor hooks require every relation referenced by a managed query to belong to one Paxos group. A write is transformed into SQL text, appended to the group log, and replayed. Writes on replicated tables are forbidden inside an explicit transaction block, and only single-statement execution is supported in the replay path.
Safety and Compatibility
Connection strings are stored in pgp_metadata tables and used by dblink; protect the schema and avoid embedding long-lived passwords where possible. The SQL-log design requires deterministic behavior. Sequences, triggers, mutable functions, time and random values, external side effects, and schema drift can all cause divergence or duplicate effects. Enabling pg_paxos.allow_mutable_functions removes only one guard and does not make such operations safe.
Version 0.2 dates from 2016 and contains server-internal compatibility code only for PostgreSQL 9.4, 9.5, and 9.6. It lacks the operational maturity, upgrade path, monitoring, recovery procedures, and modern PostgreSQL support expected of production consensus systems. Treat strong as the algorithm’s intended mode in this experimental implementation, not a current service guarantee; independently test failures, partitions, membership changes, crash recovery, and data reconciliation in disposable environments.