
How to Avoid Two Primaries When a Database Drops: Unplanned PostgreSQL Failover in Neki
When a controller loses contact with a PostgreSQL primary, rushing to fail over is dangerous. You might promote a second primary and trigger split-brain. Here is how PlanetScale's Neki checks if the primary is truly dead using pg_stat_wal_receiver, blocks the old node from returning with a // prefix in primary_conninfo, picks a new leader by LSN, and puts the failed server into TEARDOWN.






