All Products
Search
Document Center

PolarDB:Automatic failover and manual failover

Last Updated:Mar 28, 2026

PolarDB clusters automatically fail over from the primary node to a read-only node when the primary fails. For planned maintenance or high availability testing, you can also trigger a failover manually by designating a specific read-only node as the new primary.

Before you begin

Failover interrupts the database service. Interruption duration depends on whether hot standby is enabled for the read-only node that takes over:

Hot standbyInterruption duration
DisabledApproximately 20–30 seconds
EnabledWithin 5–10 seconds
Important

In extreme cases, interruption time may exceed the typical range but never exceeds 3 minutes.

To reduce interruption time, enable hot standby on your read-only nodes. See Configure hot replica nodes.

Make sure your application can automatically reconnect to the cluster after a failover.

How automatic failover works

PolarDB Cluster Edition uses an active-active high availability architecture. When the primary node fails, the system elects a new primary from the available read-only nodes.

Each node in a cluster has a failover priority. During an election, the system follows these steps:

  1. Identify all available read-only nodes eligible for promotion.

  2. Select the node with the highest failover priority. Nodes that share the same priority have equal probability of being elected.

  3. Attempt to fail over to the selected node. If the attempt fails due to network issues, abnormal replication status, or other reasons, the system tries the next eligible node until the failover succeeds.

To view and configure the failover priority of each node, go to the Database Nodes page of the cluster and check the Basic Information section.

优先级

Perform a manual failover

Manual failover is useful when you need to test cluster high availability or promote a specific read-only node to primary.

  1. Log on to the PolarDB console.

  2. In the upper-left corner, select the region where the cluster is deployed.

  3. Find the cluster and click its ID.

  4. On the Basic Information page, go to the Database Nodes section and click the 切换 icon in the upper-right corner to switch views.

  5. Click Fail Over.

    主备切换

  6. In the dialog box, set the New Primary Node parameter and click OK.

Interruption duration follows the same rules as automatic failover. See Before you begin for details.

Prepare your application for failover

After a failover, persistent connections between your application and the cluster may not detect the changed connection state automatically. If no timeout is configured, your application waits indefinitely for the database to respond — typically leading to disconnection after hundreds of seconds, during which SQL statements fail.

Configure the following parameters to minimize recovery time:

ParameterRecommended value
connectTimeout1–2 seconds (online transaction scenarios)
socketTimeout10–15 seconds (internal network); 60–90 seconds (public network)
Note

These values are reference guidelines. Adjust based on your workload and usage patterns.

API reference

OperationDescription
FailoverDBClusterPerforms a manual failover by designating a read-only node as the new primary node.