Unit 8 of 15 · about 4 hours · derive, measure

Recovery point and time objectives and disaster-recovery failover and failback

Objectives without a derivation are wishes. RPO and RTO decompose into measurable stages, and the timeline history is what lets the old primary rejoin instead of becoming a split brain. The Systems unit on SLIs, SLOs, error budgets and recovery objectives derived series and parallel availability; here the new work is the failover and failback mechanics.

You'll be able to

  • Derive RPO from archive cadence and shipping lag under stated assumptions, and RTO from detection, decision, restore, verification and switch time.
  • Plan failover and failback across timeline forks: fence the old primary, preserve its divergent writes, and rejoin it by rebuild or pg_rewind.
  • Run a fenced failover and failback drill that records each RTO stage, counts lost acknowledged writes and names both timeline fork points.

Covers

Recovery point and recovery time objectivesDisaster-recovery failover and failback
1

Read

In this order, only the parts listed

0 of 3 done

  1. Timelines: failover forks and rejoining historyThe Internals of PostgreSQL - Base Backup and Point-in-Time Recovery

    10.3 timelineId and Timeline History File (timelineId, Timeline History File); 10.4 PITR with Timeline History File (page read 2026-10-15)

    Read for why promotion forks a timeline and what the history file records. Leave 10.5 Incremental Backup for later.

  2. Rejoining a diverged primaryPostgreSQL 18 Documentation - Recovery Targets, Backup Verification and Rewind

    pg_rewind: Description (timeline divergence, the clean-shutdown and wal_log_hints or data checksum prerequisites) and the warning on failures while rewinding

    A fresh base backup is the fallback when the prerequisites do not hold.

  3. Recovery principles: speed, time and rollback trade-offsGoogle SRE Books - SLOs, Monitoring, Overload, Cascades, Incidents and Recovery

    Design Principles for Recovery (Design to Go as Quickly as Possible; Limit Your Dependencies on External Notions of Time; Rollbacks Represent a Tradeoff Between Security and Reliability)

2

Focus on

  • RPO counts data, RTO counts time. If every WAL segment closes within 15 minutes, ships to durable storage within 5 more, and the base backup plus WAL chain is intact, recoverable data is at most 20 minutes old; measure and alert on each assumption.
  • Promotion forks the timeline and the history file records the fork point. The old primary still holds a divergent tail: fence it before promotion, preserve those writes for reconciliation, then rebuild it or run pg_rewind before it follows the new timeline.
  • Failback is a second failover with the same stages: detect, decide, replay, verify, switch. Skipping verification repeats the original incident in reverse.
  • Failback promotes again, so a round trip forks the timeline twice. Record both fork points and the acknowledged writes that asynchronous failover may have lost.
Common mistakes · 3
  • Promising zero RPO on asynchronous replication. Only synchronous acknowledgement bounds data loss; async always risks the unsent tail.
  • Rejoining the old primary without the timeline history. Two writers on divergent timelines is a split brain wearing a recovery badge.
  • Treating a nominal RPO as a promise. A failing archive command stalls shipping while WAL piles up; alert when the newest archived segment ages past the bound.
3

Try it yourself

Closed-book, before checking anything

Without notes, derive the RPO bound for a 15-minute archive cadence with 5-minute shipping lag and state its assumptions. Then write the failover and failback runbook for one primary and one standby with the fence step, both timeline fork points and the RTO stage each step belongs to.
4

Quiz yourself

Answer first, then mark it. Missed ones go to Review.

0 got · 0 missed

  1. 1.WAL archives close every 15 minutes and ship within 5 more. What RPO can you state, and on what conditions?Answer

    At most 20 minutes of writes, provided segments really close on schedule, shipping meets its bound, and the base backup plus WAL chain has no gaps. Restore speed affects RTO, not RPO.

  2. 2.Detection takes 2 minutes, the decision 5, restore 30, verification 10 and the switch 1. What is the RTO, and which stage do you shrink first?Answer

    48 minutes. Restore dominates, so a faster restore or a warm standby buys the most; skipping verification saves 10 minutes at the risk of repeating the incident.

  3. 3.A failover and a later failback both promote a server. How many timeline forks does the round trip create?Answer

    Two. Each promotion starts a new timeline, and each history file records its own fork point.

  4. 4.After failover, the old primary returns with unreplicated writes. What must happen before it rejoins?Answer

    It stays fenced. Preserve its divergent writes for reconciliation, then rebuild it or run pg_rewind with its prerequisites so it follows the new timeline as a standby. It must never write the old timeline again.

You're done when

Your RPO derivation states its assumptions, and your failover and failback drill records every RTO stage, counts lost acknowledged writes and names both fork points.

Only when you can do this without notes.

Leads to

Notes

Resources · 3 for this unit, 14 more in the section
  • Google SRE Books - SLOs, Monitoring, Overload, Cascades, Incidents and RecoveryGoogle · required

    Read SRE Chapter 4 (service level objectives), 6 (monitoring distributed systems), 21 (handling overload), 22 (addressing cascading failures), 14 (managing incidents) and 15 (postmortem culture); Workbook Chapter 2 (implementing SLOs) and 5 (alerting on SLOs); and Building Secure and Reliable Systems Chapter 5 (least privilege) and 9 (design for recovery). Convert each into one alert, limit, load test or runbook action in the capstone.

  • The Internals of PostgreSQL - Base Backup and Point-in-Time RecoveryHironobu Suzuki · support

    Read Chapter 10 (base backup, how PITR replays WAL, timelines and incremental backup) as the real-engine model for backup integrity, recovery points and restore verification. Note the date you read it.

  • PostgreSQL 18 Documentation - Recovery Targets, Backup Verification and RewindPostgreSQL Global Development Group · reference

    Read Section 19.5.6 Recovery Target, the pg_verifybackup reference and the pg_rewind reference for recovery stopping points, manifest checks and rejoining a diverged primary.

Also in this section

  • HLD Handbook - Reliability, Operations and Security at ScaleHLD Handbook · primary

    Read Part 6 observability, SLOs, resilience, overload, deployments, chaos, incidents and health, then Part 7 authentication, mTLS, secrets, tenancy and data governance chapters relevant to the capstone. Skip unrelated case studies.

  • DDIA 2e - Chapters 2, 5 and 14Martin Kleppmann and Chris Riccomini · support

    Use Chapter 2 "Describing Performance" for percentile and response-time vocabulary and Chapter 5 for compatibility during rolling upgrades. Chapter 14 is about predictive analytics, privacy and data governance, not operations: read its "Privacy and Tracking" section for the retention and deletion units.

  • Metastable Failures in Distributed Systems (Bronson et al., 2021)HotOS · support

    Read the trigger and sustaining-effect model of metastable failure and the retry and shedding design prompts. Its model illustrates; it does not predict.

  • Metastable Failures in the Wild (Huang et al., 2022)USENIX OSDI · support

    Read the incident study for how retries and load sustain outages after the trigger ends; it is a sample of public reports, not a rate.

  • Simple Testing Can Prevent Most Critical Failures (Yuan et al., 2014)USENIX OSDI · support

    Read the findings on error-handling code and how few nodes and events reproduce most failures, as the case for testing error paths in your campaign. Its bounds come from one sample of 2014 systems.

  • Gray Failure: The Achilles' Heel of Cloud-Scale Systems (Huang et al., 2017)Microsoft Research · support

    Read the gray-failure model (differential observability between a detector and its clients) as vocabulary for telemetry and failure detection.

  • Building Distributed Systems - The Tracer, The Securitor and The MigratorBuild Distributed Systems · optional

    Only the first three tasks of each track are free: in The Tracer, trace-context propagation, span lifecycle and a collector; in The Securitor, JWTs, the OAuth 2 code flow with PKCE and sessions; in The Migrator, schema migrations, expand and contract, and zero-downtime change. Tasks are graded in the browser after login, so treat a pass as a drill and keep your local harness as the evidence.

  • SPIFFE Workload Identity and Workload APISPIFFE Project · support

    Read the SPIFFE ID, X.509-SVID and trust bundle specifications and the Workload API (FetchX509SVID, FetchX509Bundles) to design service identity, short-lived credentials and bundle rotation. A local mock is sufficient unless a real SPIRE deployment answers a specific gap.

  • OpenTelemetry Signals and Semantic ConventionsOpenTelemetry · support

    Read signals and context propagation (W3C Trace Context traceparent, inject and extract, baggage rules), then the semantic conventions (1.44.0) for the RPC and messaging areas with their stability status. Define bounded attributes for request, node, partition, term and offset identities, and never infer global order from display timestamps.

  • Replicated Log and Stream Processor - Production ContractRoadmap-Final · support

    Add workload identity, tenant checks, audit, SLOs, capacity limits, backup and verified restore, mixed-version migration, rollback and reduced point-in-time ML data paths. Run one compound incident from detection through recovery.

  • OWASP Threat Modeling Cheat SheetOWASP · reference

    Use System Modeling (data-flow diagrams, trust boundaries, stores and processes), Threat Identification (the STRIDE table applied to components, data flows and trust boundaries) and Response and Mitigations to build the unit threat model.

  • Feast Documentation - Point-in-Time Joins and Feature RetrievalFeast · support

    Read Point-in-time joins (entity dataframes, get_historical_features, TTL backward scan, filter_by_created_timestamp) and Feature retrieval (event_timestamp as the inclusive upper bound, get_online_features without timestamps, feature services per model version, materialize refresh). Work the join logic on tiny local tables; do not deploy Feast. Page read 2026-10-15 (v0.66-branch documentation).

  • MLflow Model Registry DocsMLflow · support

    Read the Model Registry page (registered models, versions, lineage to the producing run, aliases such as @champion, and tags) and the registry tutorial promotion flow. Stages are deprecated since MLflow 2.9; use aliases and tags. Page read 2026-10-15; the versioned docs move, so re-pin the version you read.

  • DVC Docs - Data VersioningDVC · support

    Read dvc add (Description and Example: Single file) for .dvc content-hash sidecars, the dvc.yaml page with its dvc.lock file section for pipeline state, and push and pull for transfer. A local directory remote is enough; do not set up cloud storage. Page read 2026-10-15.