Instaclustr managed PostgreSQL clusters consisting of two or more nodes are automatically configured and managed for high availability. This means that if a master node (i.e. the Postgresql server that is accepting writes for the database- and server-cluster) becomes unavailable, a replica node will automatically be promoted to the master role and clients can continue to write to the database.
Further details on PostgreSQL HA and replication features are also available in the official documentation.
In PostgreSQL clusters of two or more nodes, the master will be configured to replicate all WAL entries to the other nodes, designated as “replicas”. These replica nodes are configured as hot standbys and can be queried by clients if read-only transactions are sufficient.
In addition, replicas will use synchronous replication, meaning that confirmation of a committed transaction will only be returned to the client once the replicas have written the transaction to their write-ahead logs.
When connecting to the database, clients should include multiple hosts in the connection string, along with the desired target_session_attrs (e.g. “read-write” if the client will be writing to the database and therefore must connect to the master).
For further details, refer to Specifying Multiple Hosts in the official documentation.
During a failover scenario, the following actions will be taken:
- A server becomes unresponsive (e.g. infrastructure failure or a network partition)
- Within a minute, monitoring processes will detect the failure and signal one of the replicas to promote itself to the new master
- Database clients will automatically reconnect when the original master connection terminates and cycle through available hosts in the connection string