High availabilityadvancedPro runbook

Rejoin a demoted primary with pg_rewind

After a failover the old primary has diverged. pg_rewind resynchronises it by copying only the changed blocks — but only if the cluster was built with data checksums or wal_log_hints. Without them it refuses, and the alternative is a full base backup.

Problem

What you're actually looking at

The symptom as it shows up on a real server.

A promoted standby starts a new timeline. The old primary is now a node with history that never happened on the new one, so it cannot simply start streaming. pg_rewind exists to fix that cheaply, but it depends on a decision made once at initdb time — and that decision cannot be applied retroactively to a cluster that has already diverged.

Meridian has failed over. The old primary is intact and they would rather rewind it than copy the whole database back across the network.

In plain English

When a standby is promoted it starts writing its own version of history. The old primary still has the tail of a different history, so the two disagree about what happened. pg_rewind fixes this by copying back only the blocks that differ, instead of the whole database. The catch is that it needs a way to know which blocks changed, and that only exists if the cluster was created with checksums or hint logging turned on. If it was not, PostgreSQL tells you so and there is no way to fix it after the fact — you copy everything.

ProCaptured evidence where the run produced it

Full runbook for this incident

The scenario above is free. What Pro unlocks is the fix: how to identify rejoin a demoted primary with pg_rewind, the exact SQL to trace it, PostgreSQL 18 output for the steps we captured, the resolution path, and how to stop it recurring.
  • The full identify checklist — the exact signals that tell you it's this incident
  • Every diagnostic query; PostgreSQL 18 output is attached only to the steps we captured
  • The resolution path and the pitfalls that make it worse
  • Mitigation steps to stop it recurring, plus a verify-you're-done query

More in this category

Other High availability runbooks

Neighbouring incidents that share the same diagnostic surface.

Browse all 84 runbooks →

Connected

How this connects to the rest of the library

A live view of this page's real cross-references — what explains it, what fixes it, what to tune, and where to go next. Every link is an authored relationship, not a guess.

Open in the interactive map →