ARCHIVED from builddistributedsystem.com on 2026-04-28 — URL: https://builddistributedsystem.com/tracks/coordinator/tasks/task-9-2-coordinator-failure
TASK

Implementation

Handle coordinator failures: log PREPARE before sending, log COMMIT/ABORT decision, recover from log.

Sample Test Cases

Log transaction state before prepareTimeout: 5000ms
Input
{
  "src": "c0",
  "dest": "n1",
  "body": {
    "type": "init",
    "msg_id": 1,
    "node_id": "n1",
    "node_ids": [
      "n1"
    ]
  }
}
Expected Output
{"src":"n1","dest":"c0","body":{"type":"init_ok","in_reply_to":1,"msg_id":0}}

Hints

Hint 1
Log before sending messages
Hint 2
Recovery reads log state
Hint 3
Participants query coordinator for decision
OVERVIEW

Theoretical Hub

Write-Ahead Logging

Log decision before sending. On recovery, read log to resume. Participants in PREPARED are blocked until decision known.

Key Concepts

failure recoveryblockingwrite-ahead log
main.py
python
Handle Coordinator Failure - The Coordinator | Build Distributed Systems