Skip to main content

Chapter 7 · Watch, then practise

Replication

Follow updates from primary to standby. Compare replication lag with acknowledgment delays, and distinguish receipt from application.

3 questions · 3 with related videos. Matches are based on playlist titles; broader background matches are labeled.

What to study

  • Primary and standby
  • Synchronous and asynchronous replication
  • Replica lag and failover

Chapter playlists

Choose a playlist

Notes

Distributed Systems 5.1: Replication

Martin Kleppmann · 25:21

Supplementary replication lecture for the tradeoff between acknowledgment timing and replica state.

1. Acknowledgment tradeoff

What changes when a primary waits for a standby before acknowledging a commit?

Waiting can strengthen durability, depending on the acknowledgment stage, but adds latency and may block if the required standby is unavailable. Asynchronous replication returns earlier but leaves a window of replication lag.

Distributed Systems 5.1: Replication

Martin Kleppmann · 25:21 · Background lecture

Replication background for possible loss after asynchronous failover; the transaction numbers are specific to this exercise.

2. Failover example

A primary acknowledged transactions through 105, but its asynchronous standby has only received through 102. What is at risk if the primary is lost?

Transactions 103–105 may be absent after promoting that standby. Replication lag determines the possible missing tail; having a second server does not by itself promise zero data loss. Recovery depends on whether the missing log can still be obtained.

Distributed Systems 7.3: Eventual consistency

Martin Kleppmann · 14:59 · Background lecture

Eventual-consistency background for understanding why a replica can return stale state.

3. Received is not applied

Why can a standby acknowledge receiving a transaction yet still return an older query result?

Receiving or flushing its log differs from replaying it into query-visible state. PostgreSQL’s remote_apply mode waits for the chosen synchronous standbys to replay the transaction. State the acknowledgment stage when describing a replication guarantee.

References