Cookbook recipe

Failover runbook: promote a standby safely

Applies to PostgreSQL 13–17 Last reviewed May 2026 Grounded in source
Estimated investigation4 min

Scenario

The primary is down. You must promote a standby quickly without splitting the brain or losing committed data. Diagnose it Confirm the standby is healthy and current: -- on standby SELECT pg_is_in_recovery(); -- t SELECT now()…

Investigation Path

The primary is down. You must promote a standby quickly without splitting the brain or losing committed data.

Diagnose it

Confirm the standby is healthy and current:

-- on standby
SELECT pg_is_in_recovery();  -- t
SELECT now() - pg_last_xact_replay_timestamp();

Why it happens

Promotion makes a replica a writable primary. The danger is two primaries (split brain) if the old one returns, or data loss if the standby was far behind.

This is a Pro lesson

Get every Learning Pathway and cookbook recipe — grounded in PostgreSQL source code, with diagnostics, fixes, and prevention for each topic.

Continue this lesson to learn:

  • How to fix it
  • Prevent it next time
  • Related & next steps
  • All 36 Learning Pathway lessons
  • 170+ cookbook recipes
  • Source-grounded diagnostics & fixes

Secure checkout Cancel anytime Source-grounded

Career Impact

This scenario builds production judgment and operational confidence under pressure.

Open Career Dashboard →

Keep going

Related & next steps

Was this helpful?

← All cookbook recipes