liveBook · Manning

Timeline

As explained in PostgreSQL Mistakes and How to Avoid Them

A PostgreSQL replication timeline is a WAL history branch that identifies the sequence of changes following a primary promotion or other divergence.

A PostgreSQL replication timeline records a WAL history branch created when a standby is promoted or recovery diverges. Promotion makes the new primary's subsequent WAL incompatible with the old timeline after the split. section 9.6 section 9.2

The lagging-standby promotion trap

Suppose a failed primary has two replicas, but one is behind. If automation promotes the lagging replica, the other replica contains WAL that the new primary lacks. Recovering those transactions and reintegrating them is complicated; the replicas must rewind to before the timeline split before following the new primary. section 9.6

Use timelines to reason about recovery and failover:

  • Treat promotion as a branch in WAL history, not merely a role change. section 9.6
  • Combine full physical backups with archived WAL when using point-in-time recovery; a base backup alone is insufficient. section 9.2
  • Avoid improvised failover logic that ignores lag or network partitions, because it can produce incompatible histories or split-brain primaries. section 9.6

How PostgreSQL Mistakes and How to Avoid Them covers it

How deep it goes
Explains branching, incompatible WAL, missing transactions, and rewind requirements through a lagging-standby scenario; stops short of implementation commands.
Examples
Uses a lagging replica promoted after primary failure and recovery branches selected through point-in-time recovery.
What it assumes
Assumes familiarity with PostgreSQL replication, WAL, replicas, backups, and recovery while explaining timeline branching through operational scenarios.
What you can do after
Diagnose failover consequences by recognizing timeline splits, incompatible WAL, missing transactions, and required rewind points.
How it connects
Connects timelines to WAL, replication lag, primary promotion, standby following, split-brain, point-in-time recovery, and continuous archiving.

This explainer was generated by Manning's knowledge graph from the text of PostgreSQL Mistakes and How to Avoid Them. The section links point to the parts of the book it draws on.