Perform a manual failover with Patroni
PostgreSQLPatroniCommand
# 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.
Related
- Show Patroni cluster status, topology and history
- Perform a planned switchover with Patroni
- Rebuild a broken replica with Patroni (reinit)
- Change cluster-wide parameters in Patroni (edit-config) and apply pending restarts
- Put Patroni into maintenance mode and back (pause/resume)
- Check Patroni DCS (etcd/Consul) and REST API health