The purpose of a high availability configuration is to reduce downtime when a database cluster instance becomes unavailable. This might happen when an instance runs out of memory. With high availability, your data continues to be available to client applications.
Within a site, the configuration is made up of a primary instance and a standby replica. All writes made to the primary instance are replicated to the standby replica before a transaction is reported as committed. In the event of an instance failure, you can request that the standby replica become the new primary instance. Application traffic is then rerouted to the new primary instance. This process is called a failover.
You can manually trigger a failover at any time. The failover involves the following process, in order:
GDC takes the primary instance offline.
GDC turns the standby replica into the new active database cluster.
GDC deletes the previous active database cluster.
GDC creates a new standby replica.
Update an existing cluster
You can update your high availability settings for an existing database cluster:
Console
In the navigation menu, select Database Service.
From the database cluster list, click the database cluster to update.
Select edit Edit in the High availability section.

Select Enable same zone standby to either toggle on or off the availability of a standby instance in the same zone as your primary database cluster.
Click Save.
Verify your database cluster reflects your high availability update by viewing its status in the High availability column of the database cluster list.
gdcloud
Update your database cluster's high availability configuration:
gdcloud database clusters update CLUSTER_NAME \ --availability-type HA_TYPEReplace the following:
CLUSTER_NAME: the name of the database cluster.HA_TYPE: the high availability level for the database cluster. You can setzonalorzonal_ha. Thezonalvalue is set by default.
Verify your database cluster reflects your high availability update:
gdcloud database clusters list
API
Update your database cluster's high availability configuration:
kubectl patch dbcluster.postgresql.dbadmin.gdc.goog DBCLUSTER_NAME \ -n USER_PROJECT \ -p '{"spec": {"availability": {"enableHighAvailability": HA_ENABLED}}}' \ --type=mergeReplace the following variables:
DBCLUSTER_NAME: the name of the database cluster.USER_PROJECT: the name of the user project where the database cluster was created.HA_ENABLED: the high availability level for the database cluster. You can settrueorfalse. Thefalsevalue is set by default.
Verify your database cluster reflects your high availability update:
kubectl get dbcluster.DBENGINE_NAME.dbadmin.gdc.goog DBCLUSTER_NAME \ -n USER_PROJECT \ -o yaml
Migrate to the latest high availability implementation
To verify that your high availability database cluster is using the latest implementation, check if the annotation dbcluster.dbadmin.goog/raasEnabled exists on your high availability database cluster CR. This annotation will only appear on clusters using the new implementation. If you don't have this annotation, you can enable it and migrate your cluster with the following steps:
- Check with your Infrastructure Operator that your GDC environment is upgraded to version 1.15.1 or later.
- Disable high availability on your database cluster. Wait for the
HAReadycondition to disappear, and then re-enable high availability. - After you see
HAReady in progressorHAReady setup complete, check your database cluster CR for the annotationdbcluster.dbadmin.goog/raasEnabled. If it appears, then your database cluster has been successfully migrated.
Trigger a failover
If you have configured high availability for your database cluster, you can trigger a failover. To trigger a failover, complete the following steps:
Console
In the navigation menu, select Database Service.
From the database cluster list, click the database cluster to trigger a failover for. Your database cluster must have high availability enabled to be eligible for a failover.
Click Failover.
Type the cluster's ID for the confirmation phrase and click Failover to trigger the failover process.
gdcloud
Trigger the failover for the database cluster:
gdcloud database clusters failover CLUSTER_NAMEReplace
CLUSTER_NAMEwith the name of the database cluster.
API
apiVersion: fleet.dbadmin.gdc.goog/v1
kind: Failover
metadata:
name: FAILOVER_NAME
spec:
dbclusterRef: DBCLUSTER_NAME
Replace the following variables:
DBCLUSTER_NAME, the name of the database cluster.FAILOVER_NAME, the unique name of the failover, for examplefailover-sample.