//
Search across all documentation pages
Patroni/RDS failover verification steps for PostgreSQL 18.4 clusters - structured drill workflow for agents and on-call engineers to prove HA actually works before an incident.
## Failover Drill Skill - phases
1. Pre-check: topology, lag, backups current
2. Baseline: record primary, replicas, connection endpoints
3. Failover: controlled switchover or provider failover
4. Verify: writes on new primary, apps reconnected
5. Rollback drill: optional failback to original topology
6. Document: RTO minutes, issues, runbook diffs# Patroni pre-check
patronictl -c /etc/patroni/patroni.yml list
psql -h haproxy.internal -c "SELECT inet_server_addr(), pg_is_in_recovery();"When to invoke:
# 1. Pre-check replication lag
psql -c "SELECT application_name, state, sync_state,
pg_wal_lsn_diff(pg_current_wal_lsn(), replay_lsn) AS lag_bytes
FROM pg_stat_replication;"
# 2. Switchover to replica2
patronictl -c /etc/patroni/patroni.yml switchover --master replica1 --candidate replica2 --force
# 3. Verify new primary
psql -h haproxy.internal -c "SELECT pg_is_in_recovery();" # expect f
psql
# Failover test instance only - NOT prod without change window
aws rds reboot-db-instance \
--db-instance-identifier myapp-staging-failover-test \
--force-failover
# Watch events
aws rds describe-events --source-identifier myapp-staging-failover-test --duration 30-- After app reconnect
SELECT now(), inet_server_addr();
INSERT INTO drill_log (note) VALUES ('post-failover write OK');What this demonstrates:
SELECT pg_is_in_recovery();
SELECT * FROM pg_stat_replication; -- on primary: replicas connected
SELECT slot_name, active, restart_lsn FROM pg_replication_slots;- [ ] PgBouncer/pooler detects backend change (or brief reconnect storm acceptable)
- [ ] ORM connection pool recycles within configured timeout
- [ ] Read-only analytics routes to replica endpoint still valid
- [ ] Background jobs resume without manual pod restart| Metric | Target |
|---|---|
| Detection to promotion | < 60s Patroni, provider-specific RDS |
| App error rate spike | < 30s at p99 |
| Replication lag post-drill | < 16 MB sustained |
| Alternative | Use When | Don't Use When |
|---|---|---|
| Tabletop exercise | Comms/legal review only | Proving technical RTO |
| Chaos kill -9 postgres | Test crash recovery | First drill of quarter |
| Provider SLA trust | Hobby tier | Contractual RTO/RPO |
Annual controlled prod drill with stakeholder comms, or rely on staging quarterly if prod Multi-AZ failover is provider-managed and staging matches parameter family.
No. Failover drills HA topology; PITR Drill Runbook drills data recovery.
Switchover is graceful (planned). Failover is unplanned leader loss. Practice both; skill defaults to switchover on staging.
Stack versions: This page was written for PostgreSQL 18.4, Patroni 4.x, RDS PostgreSQL 18, and PgBouncer 1.24+.