Search code examples
postgresqlapache-zookeeperhigh-availabilityetcdpatroni

What is the consistency of Postgresql HA cluster with Patroni?


What is the consistency of Postgresql HA cluster with Patroni?

My understanding is that because the fail-over is using a consensus (etc or zookeeper) the system will stay consistent under network partition.

Does this mean that transaction running under the serializable Isolation Level will also provide linearizability.

If not which consistency will I get Sequential Consistency, Causal Consistency .. ?


Solution

  • In a distributed context, where we have multiple replicas of an object’s state, A schedule is linearizable if it is as if they were all updated at once at a single point in time.

    Once a write completes, all later reads (wall-clock time) from any replica should see the value of that write or the value of a later write.

    Since PostgreSQL version 9.6 its possible to have multiple synchronous standy node. This mean if we have 3 server and use num_sync = 2, the primary will always wait for write to be on the 2 standby before doing commit.

    This should satisfy the constraint of linearizable schedule even with failover.

    Since version 1.2 of Patroni, When synchronous mode is enabled, Patroni will automatically fail over only to a standby that was synchronously replicating at the time of the master failure. This effectively means that no user visible transaction gets lost in such a case.