DBAtlas · Database operations atlas

Perform a manual failover with Patroni

PostgreSQLPatroni

Command

# Manual failover while the leader is unhealthy (candidate is mandatory):
patronictl -c /etc/patroni/patroni.yml failover <cluster> --candidate <member> --force
# Verify the result and the new timeline:
patronictl -c /etc/patroni/patroni.yml list <cluster>
patronictl -c /etc/patroni/patroni.yml history <cluster>

What it does

Promotes the specified replica regardless of the leader's state; intended for cases where automatic failover did not happen or chose the wrong node.

When to use it

When the leader is unreachable/unhealthy and automatic failover did not kick in (e.g. in pause mode), or when you must force a move to a specific node.

Caution

With asynchronous replication, transactions not yet received by the candidate are lost (RPO > 0). If the leader is healthy, use switchover instead of failover. When the old leader returns it may need pg_rewind (if use_pg_rewind is enabled) or a reinit.

Open in DBAtlas →

Related