pasttheabstractEdition 4 · week of Oct 17

Four prompts, in order. Each builds on the last. Write as you go; your notes stay on this device and work offline.

  1. Rebuild it

    Build a toy Raft in one process: five server objects, S1 to S5, and a fake network that can delay, drop or hold back any message, driven by a fake clock and a seeded random number generator so every run can be replayed. Use Figure 2 as your spec. Implement random election timeouts, RequestVote with the up-to-date rule, AppendEntries with the previous-entry check, nextIndex backoff, and the rule that a leader counts copies only for entries from its own term. Leave out membership changes and log compaction. Test it two ways. First, script the story's run: Ana's entry commits in term 1, Bo's reaches only S2 before S1 crashes, S5 writes Cy's entry in term 2 and crashes, and S1 leads term 3. Check that S1 does not commit Bo's entry until its own no-op at index 3 is on a majority. Then delete the own-term rule and find the run where S5 erases an entry S1 has already applied. Second, run a few thousand random seeds with crashes and dropped messages, and after every step assert that no term has two leaders and no two servers have applied different commands at the same index.

  2. Challenge it

    Raft assumes a crashed server comes back with everything it wrote to disk: its current term, who it voted for, and its log (Figure 2 says to save these before replying). Suppose a disk is wiped instead, and the server restarts empty under its old name. Show where Raft's safety argument breaks. Start from Ana's entry committed on S1, S2 and S3 while S4 and S5 are still behind, then wipe S3. Find a sequence of crashes and votes that loses Ana's committed entry, and a second one that gives some term two leaders. For the lost entry, name the step of section 5.4.3's overlap argument that no longer holds; for the two leaders, name the step of section 5.2's argument that a majority vote elects at most one leader a term.

  3. Stress it

    Section 9.3 only crashes the leader. Try a partial cut instead: S1 leads and can still reach S2, S4 and S5, but the link between S1 and S3 drops for a minute, while S3 can still reach everyone else. S3 hears no heartbeats, so it times out again and again, raising its term each time. Work out what the other servers do with its vote requests, first without and then with section 6's rule that a server ignores vote requests while it has recently heard from a leader. Then the link comes back: what does S1 do when S3's reply carries a much higher term, can S3 win the election that follows, and how long is the cluster without a leader?

  4. Compare it

    Rerun the Dynamo edition's evening on Raft. Oak sits in East, Pine and Elm in West, and Pine leads a three-server Raft group. The link between East and West drops, and Maya's phone sends “add lamp” to Oak while a second request sends “add book” to Pine. For Dynamo and for Raft, say which writes succeed, what the next read of Maya's cart returns on each side, and what happens when the link comes back. Then say what Raft gains by refusing writes on one side, what it costs Maya, and which design you would pick for a shopping cart and which for the configuration store in the story.