← The Books

One Writer at a Time

Many replicated systems put a single leader in charge at a time so that operations can be ordered without dueling ballots. When that leader crashes or falls silent, how does a new leader take over without losing anything the previous leader promised?

To find out, we visit Schedia, a sister city on the northern section of Paxos with laws of its own, where five legislators maintain the city's law with one of them at a time serving as the writer, and see how a new writer takes over whenever the previous one goes silent.

We find out by following the protocol directly: a group of five replicas with one primary at a time, and how a new primary takes over whenever the old one goes silent without losing anything committed.

After Brian M. Oki and Barbara H. Liskov, Viewstamped Replication: A New Primary Copy Method to Support Highly-Available Distributed Systems, 1988

The Tholos of Schedia from above and afar on its square paved terrace on the headland: a runner hurries out of the porch, two legislators walk across the paving towards it and a citizen with a petition comes up the path, olive trees round it and the sea beyond
Where this book sits
Leads to
  • Practical Byzantine Fault ToleranceCastro & Liskov 1999 · Keeping Order Among Liars
  • Viewstamped Replication RevisitedLiskov & Cowling 2012
  • In Search of an Understandable Consensus AlgorithmOngaro & Ousterhout 2014

Each link traces an idea that one paper borrowed from another. Point at a link, or tap it, to see how.

a paper this book retells a paper retold in another book a paper outside the series

The Tholos from its paved court: legislators in red, blue, saffron and green coming and going before the gabled porch and its open door, two runners crossing the court in the distance
The Tholos of SchediaThe model

Five legislators, one lawFive replicas, one log

Schedia, the independent city on the northern section of Paxos, makes its own laws in the Tholos, a round stone hall on the summit above the town, looking across the bay toward the Paxon Chamber. Just as in the Chamber, the acoustics are so poor that no voice carries across the floor, so every word goes by messenger.*Five replicas of a service communicate only by messages: none can see another's state directly. Messages can be delayed, reordered, or lost, and replicas may be cut off or may crash and recover.

Slow messengersMessengers across the floor can be delayed, reordered, or lost altogether.An unreliable networkMessages can be delayed, reordered, or lost altogether.
Stepping out, going homeA legislator may step out onto the porch for a while, out of reach but not absent (a network partition), or go home for the night and return to smooth wax tablets in the morning (a crash and recovery).Partitions and crashesA replica may be cut off for a while (a network partition) or crash and recover with its memory empty.
Nobody liesEvery legislator and messenger is honest: whatever they write or report is truthful, and no one ever forges a note.No Byzantine faultsEvery replica and every message is honest: whatever is written or reported is truthful, and no one ever forges a message.
What is kept

The council and its lawThe group and its log

Schedia's council has five legislators. Okios, Liskovia, Kleon, Melissa, and Theron. Each sits at their own stone bench along the wall and keeps a complete copy of the city's law on wax tablets:The group has five replicas, R1 to R5. Each keeps a complete copy of the service's log:

The law grows line by line: harbour dues are two obols a hull; the cove is closed to nets in spring; the dues above are halved for boats of Schedia. Every bench's copy must record the exact same lines in the exact same order, because later lines depend on earlier ones, halving the harbour dues means nothing unless the dues have already been set.The log grows record by record: set the first key to 2; delete the second key; halve the first key. Every replica's copy must record the exact same records in the exact same order, because later records depend on earlier ones, halving a value means nothing unless it has already been set.

Even as legislators step out or go home and messengers dawdle across the floor, the council owes the citizens of Schedia two strict guarantees:Even as replicas are cut off or crash and messages dawdle, the group owes its clients two strict guarantees:

First guarantee · Consistency

One lawOne log

All five copies act as if they were a single law scroll kept in a single place. No citizen ever sees two different laws occupying the same line.All five copies act as if they were a single log kept in a single place. No client ever sees two different records occupying the same position.

Second guarantee · Durability

Passed stays passedCommitted stays committed

Once a law has been declared passed (committed), it stands permanently in its place, no matter who becomes writer afterward.Once a record has been declared committed, it stands permanently in its place, no matter which replica is primary afterward.

With five copies of the law and legislators constantly coming and going, the council must still decide what goes into the law next without conflicting ballots.With five copies of the log and replicas constantly coming and going, the group must still decide what goes into the log next without conflicting proposals.

In the paper · the group and its failures

A module group of cohorts behaves as a single logical entity; nodes may crash (fail-stop) and recover; the network may lose, delay, duplicate, and reorder messages and may partition; failures are non-Byzantine. Events known to a majority of cohorts survive view changes. (§§1–2, §4.)

Who decides what goes in

The writerThe primary

Unlike the Synod in the Chamber across the bay, where any priest may start a ballot, the Tholos has a designated writer. Only one legislator holds this office at a time: the writer (the paper's primary). Only the writer may write new lines into the law.Unlike Paxos, where any replica may start a ballot, here a single replica, the primary, is in charge at a time. Only the primary may append new records to the log.

The writer is an office, not a seat: it gives its holder no special dress and no place of honour. Each legislator sits at their own stone bench along the wall, equipped with their own wax tablets and bronze seal kit. The writer receives each citizen's petition at their bench, writes the new line of law, presses the seal beside it, gives it the next number and sends copies out by runner; the other four legislators sit passively at their benches as copiers (as backups) and simply copy the lines the runners bring them. Three rules govern the writer's work:The primary executes client calls, assigns each new record its number, and sends it out; the other four replicas are passive backups and simply apply the records the primary sends them. Three rules govern the primary's work:

Inside the Tholos: a legislator in saffron sits writing at her bench by the red-painted wall while a runner stands beside her, other council members seated at their benches along the wall, the open door bright beyond a fluted column
First · Writing

Only the writer writesOnly the primary writes

The writer receives each citizen's petition, writes the new line of law on their own tablets, gives it the next line number, and hands it to the runners.The primary receives each client's request, appends the new record to its own log, gives it the next record number, and hands it to the communication buffers.

Second · RunningSecond · Delivery

Runners never skip a lineMessages never skip a record

Each bench has a dedicated runner (the paper's communication buffer) who delivers lines strictly in order without ever skipping a number. A runner may be delayed, but any copier that holds Line 12 is guaranteed to hold Lines 1 through 11 as well.Each backup has a dedicated communication buffer that delivers records strictly in order without ever skipping a number. A message may be delayed, but any backup that holds record 12 is guaranteed to hold records 1 through 11 as well.

Third · PetitionsThird · Calls

Citizens petition the writerClients call the primary

Citizens at the door send their petitions (client calls) to the writer. If a petition accidentally goes to a copier's bench instead, that copier simply sends it back with the current writer's name.Clients send their calls to the primary. If a call accidentally goes to a backup instead, that backup simply sends it back with the current primary's identity.

Once the writer writes a new line and dispatches the runners to the copiers' benches, the citizen who petitioned is waiting at the door for an answer. The writer must know how many runners have to return before the new line can safely be declared passed into law.Once the primary appends a new record and sends it to the backups, the client that called is waiting for an answer. The primary must know how many backups have to acknowledge before the new record can safely be declared committed.

In the paper · primary, backups and the communication buffer

The primary executes client calls and generates event records; backups are passive and apply event records received from the primary. The primary's communication buffer delivers event records reliably and in timestamp order to every backup in the current view; if delivery fails for too long, a view change is triggered. Any cohort that is not the active primary rejects client calls, returning the current viewid and primary identity. (§2, §3.3.)

When the writer may say “it is law”When the primary may say “it is committed”

When a law passesWhen a record commits

A new line becomes law as soon as it is held by a majority of the council, which out of five legislators means at least three: the writer plus at least two copiers (a sub-majority of backups).A new record becomes committed as soon as it is held by a majority of the group, which out of five replicas means at least three: the primary plus at least two backups (a sub-majority of backups).

Because three out of five is enough, the writer never has to wait for everyone. As each runner returns from a copier's bench, they bring the copier's confirmation: "I hold everything up to Line 12." The moment two copiers have confirmed Line 12, three legislators in all (the writer plus those two copiers) hold it: Line 12 passes, and the writer tells the waiting petitioner that it is law. Try it below with Okios as writer while Theron has stepped out.Because three out of five is enough, the primary never has to wait for everyone. As each backup acknowledges, it reports: "I hold everything up to record 12." The moment two backups have acknowledged record 12, three replicas in all (the primary plus those two backups) hold it: record 12 is committed, and the primary tells the waiting client. Try it below with R1 as primary while R5 is cut off.

The runners go out and come back with a wordThe messages go out and come back with an acknowledgment

The Tholos from above, with five stone benches along the wall. Click a copier's bench to have that legislator step out of reach, or come back.Each lane is one replica, with real time running left to right; the ringed name is the primary. Each arrow is a record going out or an acknowledgment coming back, dashed while in transit; a hatched lane is cut off. Click a backup's name to cut it off, or reconnect it.

11last line writtenlast record appended11passed up tocommitted up to

Okios is the writer. Theron has stepped out. Write the next line.R1 is the primary. R5 is cut off. Append the next record.

Passed means three hold itCommitted means three hold it

A law has passed when its line, and every line before it, is held by the writer and at least two copiersA record has committed when it, and every record before it, is held by the primary and at least two other replicas

Waiting for three out of five solves two problems at once. First, up to two legislators can step out of reach without stalling the city's business. Second, if the writer goes home tomorrow and a new writer takes over after polling a majority of three legislators, any two majorities of five must overlap in at least one legislator, the exact same quorum-intersection principle used in the Chamber across the bay.*Waiting for three out of five solves two problems at once. First, up to two replicas can be cut off without stalling the group. Second, if the primary fails tomorrow and a new primary takes over after polling a majority of three replicas, any two majorities of five must overlap in at least one replica, the exact same quorum-intersection principle used in Paxos.*

Any line that the writer has written on their tablets but that has not yet reached two copiers is merely a draft. If the writer goes home before a draft reaches a majority, a change of writer may discard that draft, which is completely harmless, because no citizen was ever told it had passed.Any record that the primary has appended but that has not yet reached two backups is merely a draft. If the primary fails before a draft reaches a majority, a view change may discard that record, which is completely harmless, because no client was ever told it had committed.

There is a catch, however: if every writer numbers their lines starting from 1, or continues numbering while another writer takes over, "Line 12 written by Okios" cannot be told apart from "Line 12 written by Liskovia".There is a catch, however: if every primary numbers its records starting from 1, or continues numbering while another primary takes over, “record 12 appended by R1” cannot be told apart from “record 12 appended by R2”.

In the paper · waiting for a sub-majority

The operation force-to(v) waits until a sub-majority of backups (one fewer than a majority of the group configuration) acknowledge receiving every event of the current view up to timestamp v.ts; together with the primary itself, a full majority then holds the event. (§3. In Oki and Liskov's full distributed-transaction system, force-to is invoked at transaction prepare and commit; in our single-group telling, passing a law stands for committing an operation.)

In the paper · waiting for a sub-majority

The operation force-to(v) waits until a sub-majority of backups (one fewer than a majority of the group configuration) acknowledge receiving every event of the current view up to timestamp v.ts; together with the primary itself, a full majority then holds the event. (§3. In Oki and Liskov's full distributed-transaction system, force-to is invoked at transaction prepare and commit; in a single group, committing a record stands for committing an operation.)

Numbers that survive a change of writerNumbers that survive a change of primary

Seal and lineView and timestamp

Every term under one writer gets its own seal (a view): a bronze disc with five radial spokes for the five benches. In the center is a slot for the seal's number. Inside are two concentric rings of peg holes—the inner ring marked for the manager who called the seal, and the middle ring marked for the writer who writes under it. Around the outer edge, five signet sockets hold the seals of whoever answered the call. An empty socket leaves smooth wax.Because a record number makes sense only under a single primary's term, every period under a single primary is a view, with an identifier of its own (a viewid) and a fixed set of members.

Seal 7, Liskovia what each slot saysView 7 what it records

7 Λ Κ Μ empty outer: did not answer (Okios, Theron) outer ring: who answered (signets at Λ, Κ, Μ) middle ring: who writes (peg at Liskovia) inner ring: who called (peg at Liskovia) center: the number (7) spokes: align with the five benches Order: by center and inner ring alone (number, then manager); writer and outer ring don't count 6Ο < 7Κ < 7Λ < 8Θ view 7 viewid = ⟨7, R2⟩ (the only part that orders views) primary = R2 members = {R2, R3, R4} Order: by viewid alone, counter first, then replica ⟨6, R1⟩ < ⟨7, R2⟩ < ⟨7, R3⟩ < ⟨8, R5⟩
  • Center: the rising number, one higher than any seal seen so far.viewid counter: a rising counter one higher than any view seen.
  • Inner ring: a peg at the spoke of who called the seal (the manager). Together with the center number, this forms the seal's unique identity.view manager: the replica that initiated the view; paired with counter as ⟨cnt, mid⟩.
  • Middle ring: a peg at the spoke of who writes under this seal (the writer).primary: one of the members.
  • Outer ring: signets of who answered the call, each at their own bench's place.Members: the view manager and the replicas that accepted.
  • Fixed: a seal never changes; anyone missing who returns needs a new seal.Fixed: a replica outside the view that becomes reachable needs a new view.
  • Unique: only its manager pegs their spoke on that number, so no two seals share an inner core.Unique: only its starter puts its identity on a viewid, so no two views share one.
Close on a bench's stone stand in the Tholos: a stack of wax tablets and a red wax print, and on the pillar beside it the round bronze seal with its tray of dies

The writer presses the seal beside every line they write, and under each new seal the line numbers start fresh from 1. Thus every line of law is uniquely identified by its seal and line (a viewstamp = ⟨viewid, ts⟩). When comparing two marks, the one from the later seal always wins; within the same seal, the higher line number wins. Each legislator also keeps a compact note (their history) in the margin of their tablets recording the last line they hold for each seal they have served under. Pick any two marks below to see how they compare:Whenever a new view starts, record numbers start fresh from 1. Thus every record is uniquely identified by its view and timestamp (a viewstamp = ⟨viewid, ts⟩). When comparing two viewstamps, the one from the later view always wins; within the same view, the higher timestamp wins. Each replica also keeps a compact history recording the last timestamp it holds for each view it has served in. Pick any two viewstamps below to see how they compare:

Which is the later? choose two marksWhich is the later? choose two viewstamps

Choose any two.

The later line knows moreThe later viewstamp knows more

A copy with a later seal-and-line mark holds every passed law that an earlier mark holdsA copy with a later viewstamp holds every committed record that an earlier viewstamp holds

A later mark always knows at least as much passed law as an earlier one. Within a single seal, this holds because runners never skip a line: anyone who holds Line 12 of Seal 6 necessarily holds Lines 1 through 11 of Seal 6 as well. Across different seals, it holds because every new seal opens with its new writer sending their entire law copy out as the new seal's opening line, so anyone who holds even Line 1 of Seal 7 already holds everything Seal 7 started with! Notice that a raw line number means nothing without its seal: Seal 6, Line 40 may have a bigger line number than Seal 7, Line 1, yet Seal 7, Line 1 is the later mark.A later viewstamp always knows at least as much committed history as an earlier one. Within a single view, this holds because messages never skip a record: anyone who holds record 12 of view 6 necessarily holds records 1 through 11 of view 6 as well. Across different views, it holds because every new view opens with its new primary sending its entire log out as the view's opening record, so anyone who holds even record 1 of view 7 already holds everything view 7 started with! Notice that a raw record number means nothing without its view: view 6, record 40 may have a bigger number than view 7, record 1, yet view 7, record 1 is the later viewstamp.

When the writer steps out or falls silent, one of the copiers at the benches has to notice, and call for a new seal.When the primary is cut off or falls silent, some backup has to notice, and start a new view.

In the paper · viewids and viewstamps

A view identifier is a pair viewid = ⟨cnt, mid⟩, totally ordered lexicographically and unique to its creator mid; a timestamp ts is unique and ordered within a view; a viewstamp = ⟨viewid, ts⟩ pairs the two. Each cohort's history is a sequence of viewstamps (the largest timestamp it holds for each view it has participated in), and because event records arrive in order without gaps, its state reflects every event up to each viewstamp in its history. (§2, Figures 1 and 4.)

Who notices, and what they do

A silent writerA silent primary

The council keeps track of who is reachable through a periodic heartbeat called the roll: every so often, each legislator sends a brief note, "I am here" (I am alive), to the others.The group keeps track of who is reachable through periodic heartbeat messages: every so often, each replica sends a brief I am alive message to the others.

Whenever a copier stops hearing from the writer (or from another member), hears again from someone who was away, or has just walked back in from home, they call for a new seal from their bench and become its manager (the paper's view manager). Of course, the manager cannot tell whether a silent writer actually went home, stepped out onto the porch, or merely had slow messengers, and the manager does not need to know, because calling a new seal is safe in every case.Whenever a replica stops hearing from the primary (or from another member), hears again from someone who was cut off, or has just recovered from a crash, it starts a new view and becomes its view manager. Of course, the view manager cannot tell whether a silent primary actually crashed, was partitioned, or merely has slow messages, and it does not need to know, because starting a new view is safe in every case.

To call a new seal, the manager places their peg in the inner ring at their own spoke, inserts a number in the center one higher than any seal they have ever seen, and sends an invitation bearing that core to every bench. Any legislator who receives an invitation for a seal higher than their current one immediately accepts it, stops working under the old seal, and replies in one of two ways depending on whether they still have their wax tablets:To start a new view, the view manager picks a view counter one higher than any view it has ever seen, attaches its own identity, and sends an invitation to every replica. Any replica that receives an invitation for a view higher than its current one immediately accepts it, stops working under the old view, and replies in one of two ways depending on whether it still has its volatile state:

The Tholos from high under its roof, looking straight down: the spiral of light and dark stone on the floor, columns round it, and at the upper left a council member in green handing a tablet to the runner who sets off across the floor
First kind of reply · Normal acceptance

With tablets intactWith its state intact

"I accept, and my tablets hold up to Seal 6, Line 40", along with whether they were the writer of Seal 6."I accept, and my log holds up to viewstamp ⟨view 6, 40⟩", along with whether it was the primary of view 6.

Second kind of reply · Crash acceptance

Without tablets (after going home)Without its state (after a crash)

"I accept, but I went home and my tablets were smoothed; the stone on my bench says I last served under Seal 6.""I accept, but I crashed and my volatile state is gone; stable storage says I last served in view 6."

If two copiers notice the silent writer at the same time and both send out invitations, the higher seal wins, because no two seals ever have the same core, and the manager of the lower seal receives the invitation to the higher seal, abandons their own call, and replies to the higher seal like everyone else.If two replicas notice the silent primary at the same time and both send out invitations, the higher view wins, because no two views ever have the same identifier, the manager of the lower view receives the invitation to the higher view, abandons its own, and replies to the higher view like everyone else.

Once invitations go out and replies come back to the manager, the manager must decide whether the new seal is allowed to form, and who becomes the writer.Once invitations go out and replies come back to the view manager, it must decide whether the new view is allowed to form, and which replica becomes primary.

In the paper · the view manager and its invitations

Periodic “I am alive” messages detect changes in reachability; the cohort that initiates a view change acts as the view manager and sends invitations carrying a higher viewid. A cohort with intact volatile state replies with a normal-accept carrying its latest viewstamp and whether it was the primary; a cohort recovering from a crash replies with a crash-accept carrying only the cur-viewid recorded on stable storage. (§4.)

A change of sealA view change

Who becomes the writerWho becomes primary

A new seal can form as soon as a majority of the council has accepted the invitation, provided we can be sure that at least one of those respondents holds every law that has ever passed. When nobody has gone home and lost their wax tablets, any majority of three out of five automatically satisfies that requirement! Scroll through the seven steps below to watch Seal 7 take over from Seal 6.A new view can form as soon as a majority of the group has accepted the invitation, provided we can be sure that at least one of those respondents holds every record that has ever committed. When no replica has crashed and lost its state, any majority of three out of five automatically satisfies that requirement! Scroll through the seven steps below to watch view 7 take over from view 6.

1 · Seal 61 · View 6

Okios is the writerR1 is the primary

Under Seal 6, Line 12 has passed: Okios, Liskovia, and Kleon all hold it on their tablets. Melissa and Theron are slightly behind, holding up to Line 10. Meanwhile, Okios has just drafted Line 13 on his tablets at his bench, an unconfirmed draft that has not yet reached any copier.In view 6, record 12 has committed: R1, R2, and R3 all hold it. R4 and R5 are slightly behind, holding up to record 10. Meanwhile, R1 has just appended record 13, an unconfirmed draft that has not yet reached any backup.

2 · Silence

The roll goes unansweredThe heartbeats go unanswered

Okios steps out onto the porch, and his notes stop reaching the floor. At her bench, Liskovia stops hearing from him.R1 is cut off, and its messages stop reaching the others. R2 stops hearing from the primary.

3 · The manager3 · The view manager

Liskovia calls Seal 7R2 starts view 7

From her bench, Liskovia places her peg in the inner ring at her spoke, sets the center number to 7 (Seal 7, Liskovia), and sends an invitation to every copier.R2 picks a counter one higher than view 6, adds its own identity (view 7, R2), and sends an invitation to every replica.

4 · The answers

A majority replies with intact tabletsA majority replies with intact state

Kleon replies Seal 6, Line 12, and Melissa replies Seal 6, Line 10. Together with Liskovia's own Seal 6, Line 12, that makes a majority of three out of five, and Kleon's and Melissa's signets go into the outer ring of Seal 7! Theron's reply is slow, and nobody needs to wait for it, so his socket stays empty.R3 replies ⟨view 6, 12⟩, and R4 replies ⟨view 6, 10⟩. Together with R2's own ⟨view 6, 12⟩, that makes a majority of three out of five! R5's reply is slow, and nobody needs to wait for it.

5 · Choosing the writer5 · Choosing the primary

The latest seal-and-line becomes writerThe latest viewstamp becomes primary

Because three legislators held passed Line 12 and three legislators replied to the call, the two majorities must overlap. Therefore, whichever respondent reports the latest seal and line is guaranteed to hold Line 12 and every earlier passed law! Here Liskovia and Kleon are tied at Seal 6, Line 12, so Liskovia places the peg in the middle ring at her spoke, and becomes the writer of Seal 7.Because three replicas held committed record 12 and three replicas replied to the invitation, the two majorities must overlap. Therefore, whichever respondent reports the latest viewstamp is guaranteed to hold record 12 and every earlier committed record! Here R2 and R3 are tied at ⟨view 6, 12⟩, so R2 becomes primary.

6 · The opening line6 · The opening record

Sending out the whole law to open Seal 7Sending the whole log to open view 7

Liskovia opens Seal 7 by sending everyone on it her complete copy of the law (through Line 12) as Seal 7's opening line (a newview message). Melissa's tablets are immediately brought up to Line 12. Theron, whose socket is empty, gets nothing yet.R2 opens view 7 by sending every member of the new view its complete log (through record 12) as view 7's opening state (a newview message). R4's log is immediately brought up to record 12. R5, which is not a member, receives nothing yet.

7 · A draft is smoothed away7 · A draft is discarded

Okios walks back inR1 reconnects

When Okios returns from the porch, Liskovia hears from him again, and Theron's slow answer arrives at last. Neither has a socket on Seal 7, and a seal never changes, so Liskovia calls Seal 8, Liskovia. This time all five answer. Liskovia, Kleon and Melissa show Seal 7, Line 1, later than anything Okios or Theron can show, so Liskovia remains the writer, and her opening line of Seal 8 brings every bench up to Line 12. Okios's unconfirmed draft (Line 13 of Seal 6) is smoothed away, which is completely safe, because it never reached a majority and no citizen was ever told it had passed.When R1 reconnects, R2 receives its messages again, and R5's slow reply finally arrives. Neither is a member of view 7, so R2 starts view 8. This time all five accept. R2, R3 and R4 report ⟨view 7, 1⟩, later than anything R1 or R5 can report, so R2 stays primary, and its newview record for view 8 brings every replica up to record 12. R1's unconfirmed draft (record 13 of view 6) is discarded, which is completely safe, because it never reached a majority and no client was ever told it had committed.

What passed survivesWhat committed survives

Any law that passed under an earlier seal is preserved in every later sealAny record that committed in an earlier view is preserved in every later view

Notice one nice detail: if the old writer happens to be tied for the latest seal-and-line among the respondents, the old writer remains writer so that no tablets need to be copied unnecessarily.Notice one nice detail: if the old primary happens to be tied for the latest viewstamp among the respondents, the old primary is chosen to stay primary so that no log needs to be copied unnecessarily.

In the walkthrough above, every legislator who answered the call still had their wax tablets intact. The harder case is someone who has gone home for the night, had their wax tablets smoothed clean, and answers the call without tablets.In the walkthrough above, every replica that answered still had its volatile state intact. The harder case is a replica that has crashed, lost its state, and answers the invitation without it.

Sketch · that what passed survives, while everyone keeps their tablets

Let b and c be seals (views), ordered by their seal marks. A line has passed under b when the writer of b and at least two other copiers hold that line and every line before it. Claim. Any line that passed under seal b is held by every member of every seal that forms after b.

  1. Oki and Liskov state this argument in §§2 and 4; here we lay it out step by step across consecutive seals.
  2. Suppose a law's line passed under seal b: at least three of the five legislators held that line (and every line before it) under seal b.
  3. Let c (> b) be the very next seal that successfully forms. Seal c forms on replies from at least three of the five legislators. By majority intersection, those three respondents share at least one legislator with the three who held the passed line; assuming no tablets were lost, that shared legislator replies with seal b and a line number at or past the passed line.
  4. The new writer of seal c is chosen as the respondent with the largest seal-and-line mark (viewstamp). By The Later Line Knows More, the new writer's tablets contain everything the shared legislator's tablets contain, including the passed line.
  5. Seal c opens with the new writer sending their complete law state to every member of c, so every member of c holds the passed line, and any new lines in c are ordered after it.
  6. By induction from seal c to every subsequent seal that forms, the passed line survives in every later seal.∎
Sketch · that what committed survives, while everyone keeps their state

Let b and c be views, ordered by their viewids. A record has committed in b when the primary of b and at least two other replicas hold that record and every record before it. Claim. Any record that committed in view b is held by every member of every view that forms after b.

  1. Oki and Liskov state this argument in §§2 and 4; here we lay it out step by step across consecutive views.
  2. Suppose a record committed in view b: at least three of the five replicas held that record (and every record before it) in view b.
  3. Let c (> b) be the very next view that successfully forms. View c forms on replies from at least three of the five replicas. By majority intersection, those three respondents share at least one replica with the three that held the committed record; assuming no state was lost, that shared replica replies with view b and a timestamp at or past the committed record.
  4. The new primary of view c is chosen as the respondent with the largest viewstamp (viewstamp). By The Later Viewstamp Knows More, the new primary's log contains everything the shared replica's log contains, including the committed record.
  5. View c opens with the new primary sending its complete log to every member of c, so every member of c holds the committed record, and any new records in c are ordered after it.
  6. By induction from view c to every subsequent view that forms, the committed record survives in every later view.∎
A majority of answers is not always enough

When tablets are lostWhen state is lost

When a legislator goes home and returns to smooth wax, a simple majority of three replies is no longer enough on its own! To see why, look at Seal 6 again: suppose Line 12 passed because Okios, Liskovia, and Kleon held it, while Melissa and Theron held only up to Line 10. Now suppose Okios goes home (losing his tablets) and comes back, while Liskovia and Kleon step out. When a call for Seal 7 goes out, Okios (without tablets), Melissa (at Line 10), and Theron (at Line 10) answer, three out of five!When a replica crashes and recovers with empty memory, a simple majority of three replies is no longer enough on its own! To see why, look at view 6 again: suppose record 12 committed because R1, R2, and R3 held it, while R4 and R5 held only up to record 10. Now suppose R1 crashes (losing its volatile state) and recovers, while R2 and R3 are cut off. When the invitation to view 7 goes out, R1 (without its log), R4 (at record 10), and R5 (at record 10) answer, three out of five!

If Seal 7 were allowed to form from those three replies, the best intact tablet among them would stop at Line 10, and passed Line 12 would be lost forever! Majority overlap failed because the one person in the overlap between {Okios, Liskovia, Kleon} and {Okios, Melissa, Theron} was Okios, and Okios lost his tablets! To prevent this, Oki and Liskov require that a new seal may form only when a majority of the council has answered and at least one of three safety conditions holds:If view 7 were allowed to form from those three replies, the best intact log among them would stop at record 10, and committed record 12 would be lost forever! Quorum intersection failed because the one replica in the overlap between {R1, R2, R3} and {R1, R4, R5} was R1, and R1 lost its state! To prevent this, Oki and Liskov require that a new view may form only when a majority of the group has answered and at least one of three safety conditions holds:

Condition 1

A majority still has its tabletsA majority still has its state

At least three of the five legislators replied with intact tablets (normal acceptances). Then the three intact replies alone form a majority and overlap the three who passed Line 12.At least three of the five replicas replied with intact state (normal accepts). Then the three intact replies alone form a majority and overlap the three that committed record 12.

Condition 2

The lost tablets are from an older sealThe lost state is from an older view

Every reply without tablets names an older seal on its bench stone than the latest seal shown by a reply with tablets. Since that later seal already formed safely, everything from the older seal was already carried forward into it!Every reply without state names an older view in stable storage than the latest view shown by a reply with state. Since that later view already formed safely, everything from the older view was already carried forward into it!

Condition 3

That seal's writer still has their tabletsThat view's primary still has its state

A reply without tablets names the same seal as the latest reply with tablets, and that seal's writer replied with intact tablets. Because every line under a seal is written by its writer first, the writer's intact tablets hold every line of that seal, covering for any copier whose tablets were smoothed!A reply without state names the same view as the latest reply with state, and that view's primary replied with intact state. Because every record in a view is appended at the primary first, the primary's intact log holds every record of that view, covering for any backup whose state was lost!

May seal 7 form? set each answerMay view 7 form? set each answer

Seal 6, with writer Okios. Line 12 has passed: Okios, Liskovia and Kleon held it. Melissa and Theron held up to line 10.View 6, primary R1. Record 12 has committed: R1, R2 and R3 held it. R4 and R5 held up to record 10.

    Everyone here last served under Seal 6, so Condition 2 does not apply in this scenario. You can test all 243 combinations of how the five legislators might answer: in every single case where the rules allow Seal 7 to form, its new writer has Line 12!Everyone here last served in view 6, so Condition 2 does not apply in this scenario. You can test all 243 combinations of how the five replicas might answer: in every single case where the rules allow view 7 to form, its new primary has record 12!

    When none of the three conditions is met, Seal 7 simply waits and does not form yet. The manager keeps trying until Liskovia or Kleon steps back inside with their intact tablets, satisfying Condition 1 so Seal 7 can safely form with Line 12 intact.When none of the three conditions is met, view 7 simply waits and does not form yet. The view manager keeps trying until R2 or R3 reconnects with its intact state, satisfying Condition 1 so view 7 can safely form with record 12 intact.

    One more hazard remains: the old writer, Okios, may still be standing out on the porch with no idea that Seal 7 has formed inside.One more hazard remains: the old primary, R1, may still be partitioned away with no idea that view 7 has formed.

    In the paper · when a view may form

    A new view may form when the view manager has received acceptances from a majority of cohorts in the group configuration, and either: (1) a majority of the group sent normal-accepts, or (2) every crash-accept has crash-viewid < normal-viewid (the highest viewid among normal-accepts), or (3) the highest crash-viewid equals normal-viewid and the primary of that view sent a normal-accept. The new primary is chosen as the respondent with the largest viewstamp (preferring the old primary on a tie). (§4.)

    On the shaded porch of the Tholos, a legislator in blue-grey hands a wax tablet to a young runner; through the open doors behind them a legislator in saffron sits at her bench inside
    Two who believe they are writerTwo replicas that believe they are primary

    The writer who has not noticedA primary that has not noticed

    Suppose Okios, the writer of Seal 6, steps out onto the porch. While no word passes through the doorway, Liskovia, Kleon, and Melissa inside the hall make Seal 7 and designate Liskovia as writer. Out on the porch, Okios knows nothing of this and his own tablets still name him writer under Seal 6.Suppose R1, the primary of view 6, is cut off from the others. While no messages get through, R2, R3, and R4 form view 7 and make R2 the new primary. Cut off, R1 knows nothing of this and still believes it is primary in view 6.

    Now two legislators simultaneously believe they are the writer (split brain)! Nothing lets Okios pass conflicting laws out on the porch, because authority rides on the seal pressed beside every line: a copier only copies lines bearing the seal configured on their bench. Even if Okios takes a petition at the porch and sends his runners into the hall under Seal 6, watch what happens when those runners reach the benches:Now two replicas simultaneously believe they are primary (split brain)! Nothing lets R1 commit conflicting records while partitioned, because authority rides on the view number carried by every message. Even if R1 accepts a client call and sends records to the others under view 6, watch what happens when those messages reach the backups:

    Can Okios pass a line? seal 6 on the porch, seal 7 insideCan R1 commit a record? view 6 on one side, view 7 on the other

    Seal 7 formed with Liskovia as manager and writer, and Kleon and Melissa in its quorum. Click Theron's bench to choose whether he answered the call in time and is on it too.View 7 formed on a majority: R2, R3 and R4. Click R5's name to choose whether it has joined view 7 yet.

    1hold the line under seal 6hold the record in view 6

    Theron has not heard of seal 7.R5 has not joined view 7.

    Two writers, one lawTwo primaries, one log

    A deposed writer who has missed a later seal can still write drafts, but can never pass themA deposed primary that has missed a later view can still append drafts, but can never commit them

    Because Seal 7 required a majority of three (Liskovia, Kleon, and Melissa) to form, all three of them have already moved to Seal 7 and reject any note bearing the old mark of Seal 6! Even if Theron has not yet heard of Seal 7 and accepts Okios's note, Okios + Theron is only two out of five, one short of a majority. Okios can never get two copiers to confirm his draft, so he can never tell a petitioner that a new law has passed. And the moment any message from inside reaches him, he learns of Seal 7 and steps down.Because view 7 required a majority of three (R2, R3, and R4) to form, all three have already moved to view 7 and reject any message bearing the old view 6! Even if R5 has not yet heard of view 7 and accepts R1's record, R1 + R5 is only two out of five, one short of a majority. R1 can never get two backups to confirm its draft, so it can never tell a client that a new record has committed. And the moment any message from the others reaches it, it learns of view 7 and steps down.

    Notice how everything we have seen, passing laws by majority and recovering safely when a writer goes home, relies on enough legislators keeping their wax tablets intact. Let us look closely at the price of writing in wax rather than indelible ink.Notice how everything we have seen, committing by majority and recovering safely when a primary fails, relies on enough replicas keeping their volatile state intact. Let us look closely at the price of keeping the log in volatile memory rather than on disk.

    In the paper · several active primaries

    “The system performs correctly even if there are several active primaries (in different partitions) at the same time… The old primary will not be able to prepare and commit user transactions, however, since it cannot force their effects to the backups.” (§4.1.)

    What going home costsWhat a crash costs

    Wax, not inkMemory, not disk

    Schedia's legislators write the law on wax tablets (volatile memory) that remain on their benches and are smoothed clean whenever their owner goes home for the night (a crash).Each replica keeps its log in volatile memory, which is lost whenever the replica crashes.

    Only two facts are chiselled into the stone of the bench itself (stable storage): the legislator's name, and the core of the last seal they joined (its number and its manager), which is recut only when a new seal forms. Stepping out onto the porch leaves a legislator's wax tablets untouched, whereas going home wipes them clean. When a legislator returns from home to smooth wax, they know only their name and the last seal's core carved into their bench: they immediately call for a new seal, answer without tablets, and recover the law from the new writer's opening line.Only a few facts are written to stable storage: the replica's identity and configuration, and the identifier of the last view it joined, which is rewritten only when a new view forms. Being partitioned leaves a replica's volatile state untouched, whereas a crash wipes it clean. When a replica recovers from a crash, it knows only its identity and the last view recorded on disk: it immediately starts a view change, answers without state, and recovers the log from the new primary's opening record.

    Writing in wax is fast, because nobody has to chisel every single line of law into stone before answering a runner! Instead, Schedia relies on the assumption that a majority of the council will not all go home on the same night. Click the benches below to send legislators home for the night and see when the council can recover in the morning, and when it halts for good:Keeping the log in memory is fast, because nobody has to write every single record to disk before answering a message! Instead, the system relies on the assumption that a majority of the group will not all crash at the same time. Click the replicas below to crash them and see when the group can recover, and when it halts for good:

    Theron sits on his marble bench against the red-painted wall of the Tholos, a blank wax tablet open on his knees; his name, ΘΗΡΩΝ, and Ο6 in a red ring are cut into the tall back above him

    Who goes home tonight? click a benchWhich replicas crash? click a replica

    Seal 6 again, with line 12 passed. In the morning all five are back and answer the call for seal 7. Those who went home answer without tablets.View 6 again, with record 12 committed. After the crashes all five are back and answer the invitation to view 7. Those that crashed answer without state.

      Stopped, never wrong

      If too many tablets are smoothed at once, the council stops forever, it never starts a new seal with a passed law missingIf too many replicas lose their state at once, the group stops forever, it never starts a new view with a committed record missing

      Oki and Liskov note two ways to make this catastrophe arbitrarily unlikely in practice: have the primary alone log to disk, or equip each machine with an uninterruptible power supply (UPS) so it can flush its volatile memory to disk when power fails.

      Across the bay, the Paxon Parliament makes the opposite trade-off: its legislators write every promise and vote in indelible ink on parchment scrolls, and its Chamber has no writer: any legislator may start a ballot. Let us set the two halls side by side.Paxos makes the opposite trade-off: its replicas write every promise and vote to stable storage, and there is no single primary. Let us set the two side by side.

      In the paper · what survives a crash

      Almost all of a cohort's state is kept in volatile memory. Only mymid, configuration, and mygroupid (written when the cohort is created) and cur-viewid (written once at the end of each view change) reside on stable storage. When a cohort recovers from a crash, it sets up-to-date = false and initiates a view change. A simultaneous crash of a majority (a “catastrophe”) “does not cause a group to enter a new view missing some needed information. Rather, it causes the algorithm to never again form a new view.” (§4, §4.2.)

      The other hallThe other protocol

      Across the bayCompared with Paxos

      Across the water, on the summit of the island's middle section, stands the Paxon Chamber, another round stone hall where speeches cannot be heard, legislators wander in and out, and messengers take as long as they take.*Paxos is the other well-known way to keep a replicated log consistent: any replica may propose, ballots compete, and replicas write their promises and votes to stable storage.

      Because each hall legislates only for its own city, their two law scrolls never conflict.* Comparing the two halls side by side shows how closely related Viewstamped Replication and Paxos really are, and where each makes its own design choice:Comparing the two side by side shows how closely related Viewstamped Replication and Paxos really are, and where each makes its own design choice:

      What the Chamber's ink buysWhat Paxos's stable storage buys

      Immunity to everyone going home at onceImmunity to everyone crashing at once

      Because a Paxon legislator writes every promise, vote, and decree in indelible ink on their scroll (stable storage on every step), the entire Parliament can go home for the weekend and resume on Monday morning with nothing lost.* Schedia's wax tablets avoid disk writes during normal operation, at the cost of requiring that a majority not lose their wax at once.Because a Paxos replica writes every promise, vote, and decision to stable storage, the entire group can crash and resume later with nothing lost.* Viewstamped Replication's volatile state avoids disk writes during normal operation, at the cost of requiring that a majority not lose their state at once.

      What Schedia's writer buysWhat the primary buys

      Strict primary-to-backup streaming

      In the Chamber, any legislator can initiate a ballot for any decree slot, and a newly elected president runs Phase 1 across open slots.* In Schedia's Tholos, only the writer ever authors lines, copiers receive them strictly in order without gaps, and switching writers is an explicit view-change step that transfers the most up-to-date log.In Paxos, any replica can initiate a ballot for any log slot, and a newly elected leader runs phase 1 across open slots.* In Viewstamped Replication, only the primary ever appends records, backups receive them strictly in order without gaps, and switching primaries is an explicit view-change step that transfers the most up-to-date log.

      What the two halls shareWhat the two share

      Overlapping majorities

      Both protocols rest on the exact same mathematical foundation: any two majorities of a group share at least one member, ensuring that whatever a majority committed in the past is discovered and preserved in the future.

      Remarkably, the two protocols were invented independently at almost the same time: Oki and Liskov published Viewstamped Replication in 1988, while Lamport's Paxos manuscript began circulating in 1989 and was published in 1998. That is why Schedia has a city and a Tholos of its own on the northern section of the island.Remarkably, the two protocols were invented independently at almost the same time: Oki and Liskov published Viewstamped Replication in 1988, while Lamport's Paxos manuscript began circulating in 1989 and was published in 1998.

      The limits

      What it does not say

      The Tholos guarantees that every passed law survives any change of writer. Five questions mark the exact boundaries of what Oki and Liskov's 1988 paper promises:The protocol guarantees that every committed record survives any change of primary. Five questions mark the exact boundaries of what Oki and Liskov's 1988 paper promises:

      Does the council always form a new seal right away?Does the group always form a new view right away?

      Not if notes keep getting delayed or lost. If a manager stops waiting too early and forms a seal without a reachable colleague, that colleague may soon call a still higher seal, causing repeated view changes. The paper notes this explicitly and recommends generous timeouts and message retransmissions: progress requires the network to settle long enough for a view to complete.Not if messages keep getting delayed or lost. If a view manager stops waiting too early and forms a view without a reachable replica, that replica may soon start a still higher view, causing repeated view changes. The paper notes this explicitly and recommends generous timeouts and message retransmissions: progress requires the network to settle long enough for a view to complete.

      What if a petitioner gets no answer before the writer changes?What if a client gets no answer before the primary changes?

      A citizen waiting at the door cannot tell whether their petition was passed just before the old writer went home or lost as an unconfirmed draft. In Oki and Liskov's transaction system, rather than risk running a non-idempotent operation twice, an unanswered call causes the enclosing transaction to abort cleanly.A client waiting for a reply cannot tell whether its call committed just before the old primary failed or was lost as an unconfirmed draft. In Oki and Liskov's transaction system, rather than risk running a non-idempotent operation twice, an unanswered call causes the enclosing transaction to abort cleanly.

      Was the paper written for a single council alone?Was the paper written for a single group alone?

      In the 1988 paper, each council (module group) is one of several that share a larger enterprise, coordinated by a two-step agreement among the councils. The telling here keeps one council on its own.In the 1988 paper, each group (module group) is one shard of a larger distributed transaction system coordinated by two-phase commit (prepare and commit). The description here keeps one group on its own.

      Could a legislator lie?Could a replica lie?

      Not in the Tholos. Here legislators may step out, go home, or miss notes, but everything they write and report is honest (crash-recovery faults). Tolerating lying legislators requires larger majorities and two-echo cross-checks of Castro and Liskov's PBFT.*Not in this protocol. Here replicas may be partitioned, crash, or miss messages, but everything they write and report is honest (crash-recovery faults). Tolerating lying replicas requires the 3f + 1 quorums and three-phase cross-checks of Castro and Liskov's PBFT.*

      How does a citizen find out who is the writer?How does a client find out who is primary?

      Citizens check the tablet at the door or ask a copier, who redirects them to the current writer, or they consult a location directory service.Clients cache the current primary's identity; if they send a call to a backup by mistake, the backup redirects them to the current primary, or they consult a location directory service.

      One primary orders every operation, and a new primary starts from the fullest log a majority can show, so nothing committed is ever lost.

      Keeping logs in volatile memory means that simultaneous crashes can halt the group, but the view-formation rules ensure it will never resume with a committed operation missing.

      Setting One Law Kept in the Tholos

      The paper behind this book

      Brian M. Oki and Barbara H. Liskov, Viewstamped Replication: A New Primary Copy Method to Support Highly-Available Distributed Systems. Proceedings of the Seventh Annual ACM Symposium on Principles of Distributed Computing (PODC), Toronto, August 1988, 8–17. — Introduces the primary-copy replication method, viewids and viewstamps, forcing event records to a sub-majority of backups, the view-change algorithm and its crash-safe formation conditions, and integration with two-phase commit.

      The ideas, plainly.

      Oki and Liskov replicate a service across a group of cohorts that may crash, recover, and suffer network partitions or lost messages, but never lie. In each view, a single cohort acts as the primary, executing client calls and streaming event records in timestamp order to the passive backups. An event is committed once a majority of the group holds it (the primary plus a sub-majority of backups via force-to).

      Each period under a single primary is a view identified by a unique, totally ordered viewid = ⟨cnt, mid⟩, and each event is tagged with a viewstamp = ⟨viewid, ts⟩. When the primary appears unreachable or membership changes, any cohort can act as a view manager and invite the group into a higher view. It collects responses from a majority of cohorts, chooses the respondent with the latest viewstamp as the new primary, and starts the new view by broadcasting that primary's full state. Because any two majorities intersect and event records arrive in order without gaps, the respondent with the largest viewstamp in a majority is guaranteed to hold every committed event.

      Because cohorts keep their logs and state in volatile memory rather than writing every event to disk, a cohort that crashes and recovers loses its log and remembers only the cur-viewid stored on disk. Three view-formation conditions prevent a new view from forming if too many cohorts have lost their volatile state to guarantee that all committed events are present: if a majority crash at once, the group halts safely rather than starting a view with missing history. Meanwhile, a deposed primary in a minority partition can do no harm because its old viewid is rejected by the majority in the new view.

      Brian Oki and Barbara Liskov appear in the council as Okios and Liskovia; Kleon, Melissa, and Theron fill the remaining three seats. The five legislators are distinguished by cloak colour: Okios in blue-grey, Liskovia in saffron, Kleon in green, Melissa in madder red, and Theron in grey.

      In the paper, term by term
      the council of five, each with a copy of the lawA module group of cohorts; the fixed set is the configuration; three or five is typical. §2.
      the law; a lineThe group state; an event record. §2–3.
      slow or lost messengers; stepping out; going homeA network that loses, delays and reorders messages and partitions; a partition; a crash. No Byzantine faults. §1.
      one law; passed stays passedThe group behaves as one logical entity; events known to a majority survive view changes. §2, §4.
      the writer; the copiersThe primary; the backups, passive. §2.
      a runner who never skips a lineThe communication buffer: reliable delivery in timestamp order. §2.
      a petition; sent back with the writer's nameA call from a client; rejection with the current viewid and primary. §3.1, §3.3.
      Passed Means Three Hold It; waiting for twoforce-to: wait for a sub-majority of backups. §3. In the paper, at prepare and commit.
      a seal; its number, manager, writer, and quorumA view; viewid = ⟨cnt, mid⟩, which alone orders views; primary; members. §2, §4.
      seal and line; the noteViewstamp = ⟨viewid, ts⟩; the history. §2.
      The Later Line Knows MoreIn-order delivery: a later viewstamp for a view implies knowledge of every earlier event in it. §4.
      the roll; the manager; an invitation“I am alive” messages; the view manager; an invitation with a new viewid. §4.
      each bench's seal kit; the opening lineThe view configuration, distributed to all replicas via newview. Replicas share no central hardware or table. §4.
      an answer with tablets; withoutA normal acceptance with the viewstamp; a crash-accept with the viewid. §4.
      when a seal may formA majority accepted, and conditions (1)–(3). §4.
      who becomes the writer; the opening lineThe largest viewstamp, the old primary if possible; the “newview” record with view, history and state. §4.
      What Passed SurvivesThe paper's informal argument; here set out by seal. §2, §4.
      Two Writers, One LawSeveral active primaries; the old one cannot force. §4.1.
      wax; the stone, with a name and a seal's coreVolatile state; mymid, configuration, mygroupid and cur-viewid on stable storage. §4, §4.2.
      coming back from homeup-to-date = false; the cohort starts a view change. §4.
      Stopped, Never WrongA catastrophe means no new view is ever formed. §4.2.
      no promise of a new sealThe algorithm is “not tolerant of lost messages and slow responses”; long timeouts, duplicate messages. §4.1.
      a petition with no answerNo reply: abort, since a retried call might run twice. §3.1.
      the piece of work settled togetherTransactions across groups, psets and two-phase commit. §3.
      asking who is the writerThe location server and each client's cache. §3.1.