Section 3 of 3 · 7 minutes
Decide whether failover is safer than waiting
Your goal
What you will be able to do
Compare standby freshness, recovery objectives, application readiness, and split-brain controls before promotion.
Why this matters at work
The practical reason
Failover is a business and data-safety decision, not only a command that promotes a server.
Learn
The idea in plain English
Confirm the primary's state, the candidate standby's replay position, estimated data loss, timeline, write readiness, and application connection plan. Fence the old primary so both servers cannot accept independent writes.
Write the decision threshold in advance: for example, fail over when the primary is unavailable and the candidate is within the approved RPO. Record who authorises any known data loss.
Remember these points
- Measure candidate freshness against the approved RPO.
- Fence the old primary before accepting writes on the new one.
- Test application reconnect and post-failover validation.
See it in SQL
Record standby replay freshness
Capture the latest replay time and WAL position for a failover decision.
SELECT
clock_timestamp() AS measured_at,
pg_is_in_recovery() AS is_standby,
pg_last_wal_replay_lsn() AS replay_position,
pg_last_xact_replay_timestamp() AS replayed_transaction_time,
clock_timestamp() - pg_last_xact_replay_timestamp() AS replay_time_gap;A replay-time gap must be interpreted with write activity; an idle primary may generate no recent transaction timestamp.
Combine this with primary WAL position, business transaction evidence, and the agreed RPO.
A timestamped standby flag, replay position, latest replayed transaction time, and simple time gap.
Useful words
Important terms
- Fencing
- Preventing the old primary from accepting writes before a replacement primary is used.
- Split brain
- Two servers independently accept writes as primary, creating divergent data.
Quick check · Not graded
Check your understanding
What must happen before a promoted standby accepts application writes?
Your progress is saved to your signed-in account.