01planetscale.com
Designing a reliable unplanned failover
Neki’s unplanned Postgres failover uses replica evidence rather than Admin’s health check alone. It declares a primary dead only when reachable replicas report broken replication without contradiction, then disconnects them to prevent the old primary from returning and to freeze WAL positions. It promotes the replica with the highest received, preferably fully replayed, WAL, reconfigures the shard, and tears down the old primary. Synchronous `ANY 1` durability helps establish write unavailability, while TCP and WAL receiver timeouts detect silent or frozen failures.