liveBook · Manning

Failover

As explained in PostgreSQL Mistakes and How to Avoid Them

Failover is the transition of service from a failed or unavailable primary system to a replica or alternate system.

Failover moves PostgreSQL service from an unavailable primary to a standby or alternate system. The tempting shortcut is a custom promotion script that selects any reachable replica. section 9.6

Why replica choice matters

Suppose the primary fails while one standby is behind in WAL replay. Promoting that lagging standby omits transactions already received by other replicas, potentially violating the expected RPO. Promotion also creates a new timeline; the other replicas cannot simply follow it and may need their WAL rewound before they can rejoin. A network partition creates another danger: a replica may be promoted while the original primary is still accepting writes. section 9.6

Safer operational guidance:

  • Use redundant standby nodes through replication rather than relying on a single database server. section 9.7
  • Avoid manual failover and homegrown scripts that may overlook lag, split-brain conditions, recovery steps, or timeline changes. section 9.6 section 9.7
  • Prefer proven PostgreSQL high-availability tools such as RepMgr, Patroni, or CloudNativePG for Kubernetes. section 9.7

How PostgreSQL Mistakes and How to Avoid Them covers it

How deep it goes
Explains promotion consequences through replication lag, WAL omission, timeline divergence, rewinding, and network partitions.
Examples
Uses a lagging standby, divergent timelines, rewound WAL, and a partitioned primary to illustrate unsafe promotion.
What it assumes
Assumes PostgreSQL replication, standby nodes, WAL, timelines, and recovery objectives such as RPO.
What you can do after
Evaluate failover designs and select proven tooling instead of trusting untested manual procedures or custom scripts.
How it connects
Connects failover with replication, standby nodes, WAL, timelines, RPO, network partitions, and high-availability tools.

Also explained in

Compare how 6 books explain failover →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of PostgreSQL Mistakes and How to Avoid Them. The section links point to the parts of the book it draws on.