Sobes.tech
Senior

Tell me about replication in PostgreSQL: master-slave, what happens when a replica fails?

sobes.tech AI

Answer from AI

In PostgreSQL, replication is usually built on a master-slave scheme, where the master is the primary server accepting writes, and the slave is a replica that receives a copy of the data for reading and backup. Replication can be synchronous or asynchronous.

When the replica (slave) fails, it stops receiving updates from the master, but the master continues to operate. In case of master failure, a failover to one of the replicas is usually required to ensure data availability. This can be automated with tools like Patroni or repmgr. After restoring the failed replica, it needs to be resynchronized with the current master to avoid data inconsistency.

Tell me about replication in PostgreSQL… - sobes.tech