Coordination & Transactions

1 / 6

Core problem

Distributed writes fail by partial success. We need protocols that stay correct under:

  • crash/restart
  • retry/duplication
  • delay/timeout
2 / 6

2PC in one slide

  • Phase 1: collect votes (commit or non-commit)
  • Phase 2: decide
    • commit iff all votes are commit
    • else abort
  • After decision: keep retrying to unacked participants

Nuance: 2PC can block if coordinator fails at bad times.

3 / 6

Saga in one slide

  • Run forward steps in order
  • On first failure, run compensations in reverse of successful steps

Safety rules:

  • compensate only successful prior steps
  • compensation must be idempotent
  • avoid double compensation from duplicate success records
4 / 6

Fencing in one slide

  • Lock grants carry monotonically increasing token per resource
  • Write accepted only if token == latest token
  • Stale token must be rejected

Also enforce idempotency by operation ID for retry stability.

5 / 6

Exercise progression

  1. Saga rollback planner
  2. 2PC decision + recovery replay plan
  3. Fencing + idempotent writes capstone

Goal: protocol correctness under failures, not just happy path.

6 / 6
Use arrow keys or click edges to navigate. Press H to toggle help, F for fullscreen.