What's Actually Happening
Patroni switchover fails to promote new primary. Database remains on old primary or cluster becomes unavailable.
The Error You'll See
```bash $ patronictl switchover
Error: Switchover failed: no healthy replica available ```
Why This Happens
- 1.No healthy replica
- 2.DCS unavailable
- 3.Replication lag too high
- 4.Node not in sync
- 5.Configuration conflict
Step 1: Check Cluster Status
patronictl list
patronictl topologyStep 2: Check DCS Status
# For etcd:
etcdctl endpoint health
# For Consul:
consul membersStep 3: Check Replication Lag
psql -U postgres -c "SELECT client_addr, state, sync_state, replay_lag FROM pg_stat_replication;"Step 4: Check Replica Health
patronictl list
# All replicas should show "running" stateStep 5: Check Logs
journalctl -u patroni -f
tail -f /var/log/patroni.logStep 6: Fix Replication Issues
# On replica:
patronictl reinit mycluster replica-nodeStep 7: Manual Switchover
patronictl switchover --force --master old-primary --candidate new-primaryStep 8: Check PostgreSQL
systemctl status postgresql
psql -U postgres -c "SELECT pg_is_in_recovery();"Step 9: Restart Patroni
systemctl restart patroniStep 10: Verify After Switchover
patronictl list
psql -U postgres -c "SELECT pg_is_in_recovery();"Related Issues
- [Fix Patroni Cluster No Leader](/articles/fix-patroni-cluster-no-leader)
- [Fix PostgreSQL Streaming Replication Lag](/articles/fix-postgresql-streaming-replication-lag)