skip to content

After a database is recovered to an earlier point and then opened for writes, its history forks into a new branch. What does that fork mean for the archived transaction logs, for existing replicas, and for future recoveries?

level: seniorimportance: should knowfreq 32%

answer

  1. promotion increments the branch/timeline id
  2. history record marks the fork position
  3. old segments still needed - do not purge
  4. replicas are divergent, not behind
  5. fence the old primary; fresh base backup now

basics

~20 s

Promotion starts a new timeline: new log records get a new branch identifier so they do not collide with the abandoned records at the same positions. The old log stays valid for recovering to points on the old branch, replicas that followed the old branch are divergent and must be rebuilt or rewound, and you should take a fresh base backup immediately.

solid answer

~1 min

When recovery stops at a target and the instance is promoted, the log positions after that target already exist in the archive - they belong to the history you just abandoned. Writing new records at those same positions would create two different meanings for one address, so engines stamp the new stream with a new **timeline / branch identifier** and record a history entry describing where the branch happened. Consequences: - **Archive**: it now holds two branches. Keep the old segments and the branch-history metadata; without them you can no longer recover to points on the old branch, and some recoveries need to follow the old branch up to the fork and then continue on the new one. - **Replicas**: anything that followed the old branch contains transactions that no longer exist upstream. It cannot simply keep streaming; it must be rebuilt from a new base backup or rewound to the fork point by a resynchronisation mechanism. - **Old primary**: it must be fenced. Two servers writing under the same identity produce split brain and two irreconcilable branches. - **Future recovery**: take a fresh base backup on the new branch straight away, otherwise every future restore has to traverse old-backup, old-branch log, the fork, and then new-branch log.

go deeper

for a junior

Know that opening a recovered database for writes creates a new branch of history and that the old backups and logs still belong to the old branch.

for a middle

Explain why the branch identifier is needed - new records would otherwise collide with abandoned records at the same log positions - and that replicas must be rebuilt.

for a senior

Run the post-recovery checklist: fence the old primary, verify the branch history in the archive, fresh base backup, rebuild or rewind replicas, adjust retention.

for a principal

Treat the fork as a lineage change across the whole data estate: standbys, backups, and downstream consumers such as warehouses and search indexes are all coupled to a history that no longer exists and need an explicit reconciliation plan.

## Why a branch identifier exists at all A transaction log is an append-only stream addressed by position. During recovery you deliberately stop before the end of that stream and discard what follows. The moment the recovered instance accepts a write, it must produce a log record - and the natural next position is one the archive already contains from the abandoned history. Without a disambiguator you would have two different records claiming the same address, and any later recovery would be unable to tell which history it was replaying. Engines solve this by tagging the log stream with a **timeline** or branch identifier that increments on every promotion, plus a small **history record** stating which branch it forked from and at what position. Archived segments are named or filed per branch, so both histories coexist. ## What this buys you - You can still recover to any point on the **old** branch, because its segments remain intact and identifiable. That matters when you discover your recovery target was wrong. - You can recover to a point on the **new** branch, and the engine knows to follow the old branch up to the fork, then switch. This is why the history metadata must be retained alongside the segments; deleting it can make an otherwise complete archive unusable. - Repeated recoveries create repeated branches; the history records form a small tree, and any recovery target must be qualified by which branch you mean. ## What it costs you **Replicas become invalid.** A standby that was streaming the old history has already applied transactions that the promoted server never had. It is not merely behind - it is *divergent*, holding records that contradict the new history at the same positions. Streaming cannot continue. The options are: - rebuild the standby from a fresh base backup of the promoted server, which is simple, safe and expensive in time and bandwidth; - use a resynchronisation tool that rewinds the standby to the fork point by undoing its divergent records and then lets it follow the new branch, which is much faster but only works when the standby retains enough information to do so. **Split brain becomes possible.** If the original primary is still running and accepting writes while the recovered copy is promoted, you have two servers with the same identity producing two branches of real, committed business data. There is no automatic reconciliation for that. Fencing the old primary - stopping it, revoking write access, removing it from the load balancer and from any automatic failover manager - is part of the promotion procedure, not an afterthought. **The archive becomes shared and confusing.** If several recovered instances write into the same archive location, branch identifiers keep their segments distinct, but retention and monitoring become harder to reason about, and a mistake in archive configuration can result in one instance overwriting another's segments. Many teams route each recovered instance to its own archive prefix precisely to avoid that. **Recovery time grows.** Immediately after a promotion, your only base backup predates the fork. Restoring to a point on the new branch means restoring that old backup, replaying to the fork, and then replaying forward along the new branch - a long, multi-stage path with more moving parts than a normal restore. Taking a fresh base backup on the new branch as soon as the instance is live collapses that path back to normal and is the standard first post-recovery action. ## Post-recovery checklist 1. Fence the old primary; make it impossible for it to accept writes or be promoted by an automatic failover manager. 2. Verify the new branch identifier and confirm the archive contains the branch-history record. 3. Take a fresh base backup on the new branch and verify archiving is working from the new instance. 4. Rebuild or resynchronise every replica; do not let a divergent standby be used for reads, because it serves transactions that no longer officially exist. 5. Adjust retention so the old branch's segments survive as long as you might still want to recover to a point before the fork. 6. Reset monitoring and connection routing to the new instance, and reconcile downstream consumers - queues, caches, search indexes, data warehouses - that consumed the abandoned transactions. The conceptual point worth carrying away: recovery is not a rollback of a single database's contents. It creates a new lineage, and everything that was coupled to the old lineage - standbys, backups, downstream data copies - is coupled to a history that no longer exists.

  • A standby was streaming from the old primary when a recovered copy was promoted. Why can it not just reconnect and continue?
    It already applied transactions that exist only on the abandoned branch, so at the same log positions it holds different records than the new history contains. That is divergence, not lag, and streaming replication has no way to reconcile it. It must be rebuilt from a fresh base backup or rewound to the fork point by a resynchronisation tool that removes its divergent records.
  • Why take a new base backup immediately after promoting a recovered instance?
    Because your newest base backup predates the fork, so any future restore would have to replay the old branch up to the fork and then continue on the new one - slower, more fragile and dependent on retaining old segments and the branch-history metadata. A fresh base backup on the new branch returns your recovery path to a single simple restore-plus-replay.

saying these in an interview costs you the question

  • Deleting the old branch's log segments or history metadata right after recovery
  • Assuming a replica can simply reconnect to the promoted server and catch up
  • Leaving the old primary running and writable after promotion
  • Thinking the branch identifier is cosmetic rather than what keeps two histories separable
  • Skipping the fresh base backup and relying on a pre-fork backup indefinitely

context