
- PostgreSQL (on the replica)
NULL if the replica has not replayed any WAL yet.
- MySQL (on the replica)
Seconds_Behind_Master (or equivalent) can be NULL or misleading in some situations (for example, when replication threads have stopped or during long-running transactions). Check IO/SQL thread states, relay log positions, and last executed positions to get a reliable picture.
Measure replication lag carefully before promoting. For critical data (payments, invoices), estimate which time window of writes might be missing and prioritize recovery of those writes from the failed primary’s disk if possible.

- Power it off.
- Isolate it from the network (firewall rules, route changes).
- Use a fencing mechanism supported by your environment (for example, STONITH in clustered systems).
Do not promote a replica until you have a reliable way to prevent the old primary from accepting writes again. Split-brain leads to irreconcilable data divergence.
- PostgreSQL (common methods)
- MySQL MySQL replicas can be promoted by stopping replication and making the server writable, or by using orchestrators that handle configuration changes safely.
RESET SLAVE / RESET REPLICA because they remove stored replication configuration. Prefer orchestrator tools to avoid mistakes when possible.
Stage 4 — Repoint the application
Your application is likely still trying to connect to the old primary address. Many teams put a single endpoint in front of databases (virtual IP, load balancer, or DNS) so you only need to update that endpoint to redirect traffic to the new primary.
Actions to take:
- Update connection strings, failover DNS, or move the virtual IP to the new primary.
- Verify application connectivity with health checks and smoke tests.
- Monitor error rates and replication status for other replicas.
Links and further reading
- PostgreSQL documentation
- MySQL documentation
- Orchestrator for MySQL — automated topology management
- STONITH (fencing)
- Check replication lag to understand any potential data loss.
- Fence (isolate) the old primary to prevent split-brain.
- Promote the chosen replica to primary using the appropriate commands or orchestrator.
- Repoint the application (virtual IP, DNS, or client configs) and verify functionality.
