When a system failure occurs, a PolarDB cluster can automatically switch services from the primary node to a read-only node. You can specify a read-only node as the new primary node to switch services from the primary node to the read-only node.

Precautions

During an automatic failover or a manual failover, transient connections may occur. Each transient connection lasts 20s to 30s. Make sure that your applications can be automatically reconnected to the cluster.

Automatic failover

A PolarDB cluster of the Cluster Edition uses an active-active architecture that ensures high availability. If the primary node that supports reads and writes is faulty, services are automatically switched to the read-only node that is elected by the system as the new primary node.

A failover priority is assigned by the system to each node in a cluster. During a failover, a node is elected as the primary node based on the probability that is determined by this priority. The probability of being elected as the primary node is the same for the nodes that are assigned the same failover priority.

The system performs the following steps to elect the primary node:
  1. Find all the available read-only nodes that can be elected as the primary node.
  2. Select the read-only nodes that are assigned the highest failover priority.
  3. If the failover to the first read-only node fails due to network issues, abnormal replication status, or other reasons, the system attempts to switch your services to another read-only node until the failover succeeds.
Note During the failover, transient connections may occur. Each transient connection lasts 20s to 30s. Make sure that your applications can be automatically reconnected to the cluster.

In the Database Nodes section of the Overview page for the cluster, you can view and configure the failover priority of each node in the cluster.

Failover priorities of nodes

Manual failover

You can specify a read-only node as the new primary node to switch services from the primary node to the read-only node. Manual failovers are suitable for scenarios in which you need to test the high availability of a cluster or specify a read-only node as the primary node of a cluster.

  1. Log on to the PolarDB console.
  2. In the upper-left corner of the console, select the region where the cluster that you want to manage is deployed.
  3. Find the cluster that you want to manage and click the cluster ID.
  4. In the Database Nodes section of the Overview page, click Failover in the upper-right corner of the section to switch views.
  5. Click Switch Primary Node.
    1
  6. In the dialog box that appears, specify New Primary Node and click OK.
    Note During the failover, transient connections may occur. Each transient connection lasts 20s to 30s. Make sure that your applications can be automatically reconnected to the cluster.

Related API operations

Operation Description
FailoverDBCluster Manually switches services from the primary node to a read-only node of a specified PolarDB cluster. You can specify a read-only node as the new primary node.