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.
Instaclustr supports several replication modes for PostgreSQL clusters. Please read the documentation on replication mode options.
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, given they follow our recommended connection configurations, will automatically reconnect when the original master connection terminates and cycle through available hosts in the connection string
- During rejoining of the previous primary, pg_rewind will be run to ensure agreement on the current history of transactions.