Can some changes be combined in any order, any number of times, and still come out the same everywhere, so that they never clash and no one ever needs to coordinate?
We find out by exploring how the libraries of the scholars' coast keep one compendium of knowledge, each changing its own copy at once and merging the copies the couriers bring, without ever meeting to settle anything.
We find out by working with the idea directly: replicas that accept updates at once, without asking first, and merge their states in any order, any number of times, to the same result.
After Marc Shapiro, Nuno Preguiça, Carlos Baquero and Marek Zawirski, Conflict-free Replicated Data Types, 2011 · the same authors, A Comprehensive Study of Convergent and Commutative Replicated Data Types, 2011

Each link is an idea one paper took from another. Point at one, or tap it, to read how.
a paper this book retells a paper retold in another book a paper outside the series
The libraries of the scholars' coast keep one compendium of what is known, an entry to each subject, and every library keeps its own copy of the whole. Scholars at any library change an entry at once, and couriers carry copies of entries from library to library.*Several replicas each hold a copy of the same data object, a map from keys to values. Each replica accepts updates locally and immediately, and sends its state to the others in the background, with messages that may arrive late, out of order, or twice.
The compendium's entry on the comet, the long-haired star now in the evening sky, says what the comet is, how many times it has been seen, and which other entries to read beside it. Library 1 records a new sighting of the comet in the same hour as Library 2 rewrites the account of what it is. Neither has heard of the other's change.Take one value with independent parts: a count, a description and a set of links. Replica 1 increments the count at the same time as Replica 2 rewrites the description. Neither has received the other's update.
The coast's plain rule treats an entry as one thing: of two versions, the one with the larger tally stands.* Here it keeps Library 2's version and throws away Library 1's sighting, although the two changes touched different parts of the entry. Keeping both versions instead leaves a scholar to merge them by hand, at every library that receives the two.The plain rule treats the whole value as one register: of two versions, the one with the larger timestamp wins.* Here it keeps Replica 2's version and loses Replica 1's increment, although the two updates touched different parts. Keeping both versions instead leaves someone to merge them by hand, at every replica that receives the two.

Every library ends with Library 2's version. The sighting is lost, and nothing in the entry shows that it was ever recorded.Every replica ends with Replica 2's version. The increment is lost, and nothing in the state shows that it was ever made.
Every library ends with the two versions side by side, and a reader is shown both until a scholar writes one entry over them.Every replica ends with the two versions side by side, and a reader sees both until someone writes one value over them.
What is wanted is a way for every library to change its own copy at once, take in other copies in any order and any number of times, and still end with the same entry and no change lost. The way the scholars found is to stop treating an entry as one thing. Each part gets its own rule for merging, chosen so that changes made in ignorance of each other never clash. The count of sightings is the simplest part, and it already shows the whole difficulty.What is wanted is a way to update immediately, merge states in any order and any number of times, and still end with the same state and no update lost. The answer is to stop treating the value as one register. Each part gets its own merge, chosen so that concurrent updates never conflict. The counter is the simplest part, and it already shows the whole difficulty.
Anyone who sees the comet may report it at the nearest library, and that library records the sighting at once. Each of the three libraries the reports come to, numbered 1 to 3, must be able to say from its own copy how many times the comet has been seen. A library keeps the count on a marble board in pebbles (psēphoi), one to a sighting, and a courier carries a copy of the board with the entry. Every entry that counts something has a board of its own; we watch the comet's.Suppose three replicas count how many increments have been made to a shared counter. Each replica holds a single number, and the replicas share these numbers by message. A map keeps one such counter under each key, each behaving as the one shown here; nothing about the merge changes.
Suppose at first that each board held a single pile. Library 1 and Library 2 each record a sighting in the same hour, so both boards show 1, though the comet has been seen 2 times.Suppose at first that each replica kept a single number. Replica 1 and Replica 2 each increment at the same time, so both show 1, though 2 increments were made.
When a courier brings Library 1's board to Library 2, Library 2 can keep the larger pile (max(1, 1) = 1) and lose a sighting for good, or add the two piles (1 + 1 = 2). Adding is right this once. But the same board may arrive again, or the two libraries may exchange boards a second time (2 + 2 = 4), and the count climbs on sightings made only once.When a message carries Replica 1's number to Replica 2, Replica 2 can keep the larger (max(1, 1) = 1) and lose an increment for good, or add the two (1 + 1 = 2). Adding is right this once. But the same state may arrive again, or the two replicas may exchange states a second time (2 + 2 = 4), and the count climbs on increments made only once.
The libraries could take turns, or vote before recording, as the assemblies in the north do, and then every stopped courier would hold up the count. The cure has to work with couriers as they are: late, out of order and sometimes twice.The replicas could take turns or vote before incrementing, as consensus protocols do, and then every delayed message would stall the counter. The cure has to work with messages as they are: late, out of order and sometimes duplicated.

A single pile failed because two libraries added to the same pile, and a pebble arriving from elsewhere could not be told from one already counted. The cure is to cut a column (groove) on every board for each of the three libraries, as each house of Arche keeps a row for every house in its column.* Library 1 records its sightings only in Column 1, Library 2 only in Column 2, and Library 3 only in Column 3.A single number failed because two replicas incremented the same number, and an increment arriving from elsewhere could not be told from one already counted. The cure is to keep a separate entry for every replica, a vector with one entry per replica, as a vector clock does.* Replica 1 increments only Entry 1, Replica 2 only Entry 2, and Replica 3 only Entry 3.
Each column now has one writer, and each column only grows. On any library's board, a library's column holds as many pebbles as that library had recorded by the latest news to reach this board. The number of sightings is the sum of the three columns.Each entry now has one writer, and each entry only grows. In any replica's state, a replica's entry holds as many increments as that replica had made by the latest state to reach this one. The value is the sum of the three entries.
When a courier brings another library's board, the receiving library compares it with its own column by column and keeps the larger pile in each (max).When a message brings another replica's state, the receiving replica compares it with its own entry by entry and keeps the larger value in each (max).
Taking the larger pile never loses a pebble and never counts one twice, because only one library ever adds to a column. In Column 1, a pile of 4 is not a different set of sightings from a pile of 3: it is the same 3 and one more. So the merge obeys three laws:Taking the maximum never loses an increment and never counts one twice, because only one replica ever increments an entry. In Entry 1, a value of 4 is not a different set of increments from a value of 3: it is the same 3 and one more. So the merge obeys three laws:
• Order does not matter (commutative): merging Board A into Board B gives the same result as merging B into A.
• Grouping does not matter (associative): merging A with B and then C gives the same result as merging B with C and then A.
• Repetition does not matter (idempotent): merging the same board a second or third time changes nothing.• Order does not matter (commutative): merging State A into State B gives the same result as merging B into A.
• Grouping does not matter (associative): merging A with B and then C gives the same result as merging B with C and then A.
• Repetition does not matter (idempotent): merging the same state a second or third time changes nothing.
Try it below: record sightings anywhere, send boards between any two libraries in any order, as often as you like, and switch the rule to adding to see the count run away.Try it below: increment anywhere, send states between any two replicas in any order, as often as you like, and switch the merge to addition to see the count run away.
Each board has a column for every library. The shaded column is the one its own library may add to.
If two boards both know of the first two sightings Library 1 recorded, adding their columns counts those two pebbles twice, and again at every later meeting. Taking the larger pile in each column counts every pebble once, however many times and by however many paths the boards meet.If two states both know of the first two increments made at Replica 1, adding their entries counts those two increments twice, and again at every later merge. Taking the maximum in each entry counts every increment once, however many times and by however many paths the states meet.
This asks very little of the couriers. Even if every courier between Library 1 and Library 2 is stopped, both keep recording sightings and saying how many there are, and once one courier gets through each way, their boards are the same.This asks very little of the network. Even if every message between Replica 1 and Replica 2 is lost, both keep incrementing and answering reads, and once one message gets through each way, their states are the same.
A courier who carries a whole board to report one new pebble carries a great deal for little news. A slip naming the one change would be lighter.Sending the whole state to report one increment sends a great deal for little news. A message naming the one operation would be smaller.
The payload is a vector P of n naturals, one entry per replica. The update increment at replica g sets P[g] := P[g] + 1; the query value returns Σi P[i]; the merge of X and Y is the entry-by-entry maximum. A CvRDT is an object whose states form a semilattice under an order ≤, whose merge ⊔ is the least upper bound, and whose updates never decrease the state. Claim. This counter is a CvRDT, and any two replicas that keep exchanging states converge.
A courier can carry a copy of a library's whole board (the board way, or state-based, CvRDT), or a slip naming one change, one more sighting at Library 1 (the slip way, or operation-based, CmRDT). Both reach the same count, but they ask different things of the couriers.A message can carry a copy of the replica's entire state (the state-based form, CvRDT), or name one operation, increment Entry 1 (the operation-based form, CmRDT). Both reach the same state, but they ask different things of the messaging layer.
Send Library 1's one new sighting to Library 2 either way, and send it again, and watch the count at Library 2.Send Replica 1's one increment to Replica 2 either way, and send it again, and watch the value at Replica 2.
Library 2 has not heard yet.
Merging two boards by the larger pile is idempotent, so a courier with a whole board may arrive twice, out of order, or not at all, as long as some later board gets through, and the count is still right. The cost is weight: a whole board carried for one new pebble.Merging two states by the maximum is idempotent, so a message carrying a whole state may arrive twice, out of order, or not at all, as long as some later state gets through, and the count is still right. The cost is size: a whole state sent for one increment.
One sighting added commutes with another, so slips from different libraries may arrive in any order. But the same slip taken in twice counts a sighting twice, and a lost slip loses a sighting for good. In general the slip way needs every slip delivered exactly once and in causal order, so that a slip striking something never arrives before the slip that wrote it.Incrementing Entry 1 commutes with incrementing Entry 2, so operations from different replicas may arrive in any order. But the same operation applied twice counts an increment twice, and a lost operation loses it for good. In general operation-based CRDTs need every operation delivered exactly once and in causal order, so that a remove never arrives before the add it removes.
The two ways can do the same things. A board can travel as a slip that says merge this board, and a library can keep, as part of its board, every slip it has heard of and every slip it has taken in.The two forms are equivalent. A state can be sent as an operation, merge this state, and a replica can keep, as part of its state, the set of operations it knows of and the set it has delivered.
So whether the couriers carry boards or slips is a choice between the weight of what they carry and the care with which it must be delivered, not between what the two can do. The next change to the count is one that takes a pebble away.So sending states or operations is a trade-off between message size and delivery guarantees, not a difference in what can be computed. The next update to the counter is one that takes a unit away.
SEC is strong eventual consistency. A state-based object, a CvRDT, is (S, ≤, s0, q, u, m): states, their order, the initial state, query, update and merge. An operation-based object, a CmRDT, is (S, s0, q, t, u, P): states, initial state, query, prepare-update, effect-update and delivery precondition. Claim. Each can emulate the other.

Some sightings turn out to be mistaken: a falling star, or a cloud lit by the setting sun. Word of a mistake may reach any library, and the count must then go down.Some counters must also be decremented, so that the value can go down as well as up.
A library cannot simply take a pebble off a column, for the next board to arrive from another library still has the larger pile and puts it straight back. And Library 3, learning that a sighting recorded at Library 1 was a mistake, may not touch Column 1 at all. A withdrawal on this coast travels as a notice of its own, never as a missing copy,* and a struck sighting is the same: it cannot travel as a missing pebble.A replica cannot simply lower its own entry, for the next state to arrive from another replica still holds the larger value and raises it straight back. A deletion has to travel as an update of its own, never as a missing value,* and a decrement is the same: it cannot travel as a missing increment.
So each board is cut with two sets of three columns (PN-Counter): white pebbles for sightings recorded and black pebbles for sightings struck. A library that strikes a sighting adds a black pebble to its own black column, whichever library recorded the sighting. Both sets only grow, so both merge by the larger pile, and the count, all the white less all the black, can go up or down.So each state holds two vectors of three entries (PN-Counter): one of increments (the P vector) and one of decrements (the N vector). A replica that decrements adds one to its own entry of N. Both vectors only grow, so both merge by the maximum, and the value, the sum of P less the sum of N, can go up or down.
A count of sightings can never be less than nothing, and every library can read the count from its own board. Try striking the comet's one sighting at two libraries at once, first with each library reading its own board, then with each striking only what it recorded itself.A counter may have a bound: a value that must never go below zero. Every replica can read the value from its own state. Try decrementing the last unit at two replicas at once, first with each replica checking its own state, then with each decrementing only up to its own increments.
Library 1 recorded one sighting, and both boards show it. Word comes to both libraries that it was a falling star.
Two libraries that each see one sighting may each strike it, and when their boards meet the count stands at −1. A black pebble does not say which sighting it cancels, so both strikes count. Reading the board is not enough; the libraries would have to stop and agree before each strike. The way round it is to hand out the right to strike in advance, and here the split is plain: a library strikes only sightings it recorded itself, and sends word of any other mistake to the library that recorded it. No library's black pebbles can then outnumber its white, so the whole count never falls below nothing. Rights to a limit handed out beforehand are what the paper calls escrow.Two replicas that each see a value of 1 may each decrement, and the value converges to −1. Reading the local state is not enough; the replicas would have to coordinate before each decrement. The way round it is a local invariant that implies the global one: no replica may originate more decrements than increments, P[g] − N[g] ≥ 0 for every replica g, so the sum never falls below zero. Reserving such rights in advance is escrow.
A count goes up and down by pebbles. The entry's account of what the comet is cannot be counted, only written over.A counter merges because increments add up. A value that can only be overwritten needs another rule.
The entry's account of what the comet is (a register) is written whole and replaced whole. Library 1 writes at noon that the comet is a planet seen only rarely. Later that day Library 2, which has not yet seen that account, writes that the comet is dry air set alight high above the earth. Every library must end with the same account.A register holds one value that is written whole and overwritten whole. Replica 1 writes the register at noon. Later that day Replica 2, which has not received that write, writes it too. Every replica must end with the same value.
Two rules both merge in any order and any number of times. Choose one below, and the order in which the two accounts reach Library 3.Two rules both merge in any order and any number of times. Choose one below, and the order in which the two writes reach Replica 3.
Each account carries a tally, the hour and the library's number, and when two meet, the one with the larger tally stands.* The larger of two tallies is the same in any order and however often it is taken, so every library converges, and the earlier account is thrown away.Each write carries a unique timestamp, a clock reading plus a replica number, and when two meet, the larger timestamp wins.* The maximum of two timestamps is the same in any order and however often it is taken, so every replica converges, and the earlier concurrent write is discarded.
When a scholar replaces an account they have read, the new tally must be larger than the old, or the old account could win. Tallies that only ever grow, like the marks the houses of Arche keep, guarantee it.*When a replica overwrites a value it has seen, the new timestamp must be larger than the old, or the old value could win. Lamport clocks guarantee it.*
Each account carries a row of counts, one per library (version vector), saying which accounts its writer had read. An account gives way only to one written after reading it. Two accounts written in ignorance of each other are both kept, and the entry reads “some say … others say …”, as the scholia do, until a scholar reads both and writes one account over them.Each write carries a vector of counters, one per replica (version vector), recording which writes its writer had seen. A write is replaced only by a write that causally follows it. Two concurrent writes are both kept until a client reads both and writes one value over them.
Both rules give every library the same account. What separates them is what a clash should mean: a winner chosen by tally, or both accounts kept for a scholar to settle. The entry's last part, its list of entries to read beside it, is neither a count nor one account.Both rules converge. What separates them is what a conflict should mean: a winner chosen automatically, or both values kept for a client to reconcile. The last part of the value, its set of links, is neither a counter nor a register.
The entry on the comet ends with the other entries to read beside it (a set): the entry on eclipses, the entry on falling stars. If references are only ever added (G-Set), merging two lists means keeping every reference on either (A ∪ B), which cares nothing for order, grouping or repetition.Suppose the value also holds a set of links. If elements are only ever added (G-Set), merging two sets is their union (A ∪ B), which is commutative, associative and idempotent.
Scholars also strike references. A reference rubbed off one library's list comes straight back with the next list to arrive from a library that still has it. And when Library 1 adds a reference in the same hour as Library 2 strikes it, the libraries must still end alike. The paper gives three ways to keep a list that can lose references:Replicas also remove elements. An element erased from one replica's set comes straight back with the next union. And when Replica 1 adds an element at the same time as Replica 2 removes it, the replicas must still converge. The paper gives three ways to build a set with removal:
Keep two lists that only grow: references added and references struck off (tombstone set). A reference stands if it is on the first and not the second. Both merge by union, but a reference once struck can never be added again.Keep two grow-only sets: an added set and a removed set (tombstone set). An element is in the set if it is in the added set and not in the removed set. Both merge by union, but an element once removed can never be added again.
Every time a library adds a reference it writes a fresh tag beside it, unique on the whole coast: the library's number and its own count. A reference stands while any of its tags is unstruck. A library that strikes a reference strikes only the tags it can see on its own list (observed-remove).Every time a replica adds an element it attaches a fresh, globally unique tag. An element is in the set while any of its tags is unremoved. A replica that removes an element removes only the tags it can currently see (observed-remove).
A reference can instead carry the tallies of its latest adding and its latest striking, and the later stands (LWW-element-Set); or a pebble count, up for each adding and down for each striking (PN-Set), under which a reference struck twice must be added twice to come back.An element can instead carry the timestamps of its latest add and latest remove, and the later wins (LWW-element-Set); or a counter, incremented on add and decremented on remove (PN-Set), under which an element removed twice must be added twice to come back.
Each library sees only its own list until the two exchange.
A reference struck at Library 1 and later added again gets a new tag, which is on no struck-off list, so it comes back cleanly. And a strike at Library 1 made while Library 2 adds the same reference cancels only the tags Library 1 knew of, so Library 2's new tag, and the reference, stand (add-wins).An element removed at Replica 1 and later added again gets a new tag, which is in no removed set, so it comes back cleanly. And a remove at Replica 1 concurrent with an add at Replica 2 cancels only the tags Replica 1 observed, so Replica 2's new tag, and the element, remain (add-wins).
A count, an account and a list of references, each with its own rule, make up one entry. The compendium is many entries, filed under headings that can themselves be added and withdrawn.A counter, a register and a set, each with its own merge, make up one value. The map holds many such values, under keys that can themselves be added and removed.
An entry is its parts side by side. One copy of an entry is ahead of another when every part is ahead: as many pebbles or more in every column, an account written after the other's, every tag the other has. Merging two copies merges each part by its own rule, so the whole entry merges in any order and any number of times as well.A composite value is a tuple of CRDTs. One state is below another when every component is below; the merge is the merge of each component. A product of semilattices is a semilattice, so the composite is itself a CRDT.
The headings work like the references: a list in which every writing has its own tag. Writing anything into an entry writes a fresh tag on its heading. Withdrawing a heading strikes the tags the withdrawing library can see, and the entry is hidden while no tag of its heading stands; its parts are kept, and merged like any others.The keys work like the set: an add-wins set in which every update to a value adds a fresh tag to its key. Removing a key removes the tags the remover has observed, and the value is hidden while no tag remains; its components are kept and merged as before.
So a heading withdrawn at one library while another library writes into its entry still stands everywhere once the two copies meet. Try both cases below. The second shows what parts merged separately cannot do.So a key removed at one replica while another replica updates its value is present everywhere once the two states merge. Try both cases below. The second shows what components merged separately cannot do.
Library 1 withdrew the heading on what it knew. Library 2's sighting came after nothing Library 1 had seen, so its tag stands, and the comet keeps its entry and its count everywhere.Replica 1's remove covers only the tags it observed. Replica 2's concurrent update added a tag Replica 1 never observed, so the key stays present, with its counter, at every replica.
Every library now has a reference from the comet to an entry withdrawn everywhere. Each part merged by its own rule, and neither rule looks at the other part. A rule such as “no reference to a withdrawn heading” spans two parts, and keeping it needs the libraries to agree, as every rule over the whole does.Every replica now holds a link from comets to a key removed everywhere. Each component converged, and neither merge looks at the other. An invariant such as referential integrity spans components, and enforcing it needs coordination, as every global invariant does. The papers treat objects as independent and do not consider transactions.
Parts merged one by one also give results that no single order of the changes could give. Two cross-references show it.Componentwise convergence also admits outcomes that no sequential execution produces. The set shows it.
Let (S1, ≤1, ⊔1), …, (Sk, ≤k, ⊔k) be the states of k CvRDTs, each a monotonic semilattice. Their product is S = S1 × … × Sk, ordered and merged componentwise; an update applies an update of one component. A map adds an OR-Set of pairs (κ, uid) beside a product value for every key κ. Claim. The product is a CvRDT, and so is the map.
On Arche, every copy behaves as if all changes across the island had been made one at a time in a single order: sequential consistency.* The libraries' guarantee, that copies which have taken in the same changes are the same (strong eventual consistency, SEC), is a different promise.We have also met sequential consistency:* every replica behaves as if all operations were executed in a single global sequence. Strong eventual consistency (SEC), that replicas which have received the same updates are in the same state, is a different promise.
Take the comet's list of references, with a tag for every writing. In the same hour Library 1 adds a reference to the entry on eclipses (E) and then strikes the reference to falling stars (F), while Library 2 adds F and then strikes E. When both lists reach Library 3, each strike saw nothing of the other library's adding, so both E and F stand.Take a tagged set (OR-Set). Concurrently, Replica 1 adds element E and then removes F, while Replica 2 adds F and then removes E. When both states merge at a third replica, each remove observed nothing of the other replica's add, so both E and F are in the set.
Arranged in any single order, one at a time, whichever strike came last would remove its reference and leave at most one. So the libraries can agree on a list that no single order of the four changes could produce.Arranged in any single sequence, whichever remove came last would remove its element and leave at most one. So CRDTs can converge to a state that no sequential execution produces.
Putting every change into one order needs the libraries to agree, and agreement stops when too many of those who must agree fall silent.* Giving up one order, and asking only that changes merge the same everywhere, lets every library read and change its copy even when all the others are cut off.Putting every operation into one sequence needs consensus, which cannot be solved when too many replicas crash or become unreachable.* Giving up one sequence, and asking only that concurrent operations merge deterministically, keeps every replica available for reads and writes even when all the others are unreachable.
The parts give the libraries an entry they can always read and change at their own desks, merged by rules alone. Some things those rules do not give.The components give each replica a value it can always read and update locally, merged by rules alone. Some things those rules do not give.
SEC is strong eventual consistency: replicas that have delivered the same updates have the same state. Sequential consistency asks that the result be that of all updates executed in some single order. Take a Set CRDT with add-wins semantics: after add(e) ∥ remove(e), where ∥ means concurrent, e ∈ S. Claim. Neither property implies the other.
The libraries get entries they can always read and change at their own desks, and that converge by merging alone. Five things they do not get.The replicas get counters, registers, sets and maps of them that can always be read and updated locally, and that converge by merging alone. Five things they do not get.

No. A rule over the whole coast's compendium, such as a count that never falls below nothing or no reference to a withdrawn heading, cannot be kept by each library from its own copy. It needs the libraries to agree first, or rights handed out in advance.No. An invariant over the combined state, such as a counter that never goes below zero or no link to a removed key, cannot be enforced locally without coordination or rights reserved in advance.
No. Convergence promises only that every library lands on the same entry. Whether the adding wins, the striking wins, the later account stands or both are kept is a choice to be made for each part.No. Convergence guarantees only that every replica lands on the same state. Whether that is add-wins, remove-wins, last-writer-wins or keep-both is a choice the designer makes for each type.
No. A board has a column for every library, and lists with strikes keep their struck tags, as the compendium keeps its withdrawn headings. Throwing an old strike away is safe only once every library has seen it, which needs every library heard from.No. A counter has an entry for every replica, and sets and maps with removal keep tombstones. Discarding a tombstone is safe only once every replica has seen it, which needs every replica to be reachable.
Honest libraries: one that writes in another library's column or forges a tag can spoil every copy. And the slip way assumes every slip delivered exactly once, in causal order.Honest replicas (no Byzantine faults): a replica that writes another replica's entry or forges tags can corrupt the state. And operation-based CRDTs assume every operation is delivered exactly once, in causal order.
No. The comprehensive report also builds graphs, such as a web of cross-references between entries, and sequences for editing a text line by line (treedoc, RGA), on the same principles.No. The report also builds graphs, and sequences for collaborative text editing (treedoc, RGA), on the same principles.
Replicas that only ever move their state upward, and merge by taking the least state that holds both, converge without coordinating.
A rule that spans all the replicas, such as a count that never goes below zero, still needs agreement.
Setting Libraries That Agree in the End
Marc Shapiro, Nuno Preguiça, Carlos Baquero and Marek Zawirski, Conflict-free Replicated Data Types. Stabilization, Safety, and Security of Distributed Systems (SSS), 2011. — Strong eventual consistency, the state-based and operation-based sufficient conditions, their equivalence, the incomparability with sequential consistency, counters, sets and graphs.
Marc Shapiro, Nuno Preguiça, Carlos Baquero and Marek Zawirski, A Comprehensive Study of Convergent and Commutative Replicated Data Types. INRIA Research Report RR-7506, January 2011. — The portfolio: counters, registers, sets, graphs, sequences, with specifications and proofs, and a shopping cart built from them.
The ideas, plainly.
Shapiro and co-authors ask when replicas of some data can accept changes without ever talking to one another first, and still end the same. Their answer, strong eventual consistency, asks only that replicas that have received the same updates are in the same state. They give two sufficient conditions. In the state-based form the states are ordered so that each update moves a state upward and merging two states is their least upper bound; then merging commutes, groups freely and may be repeated. In the operation-based form every pair of concurrent operations commutes and operations are delivered once each, in causal order. Each form can imitate the other.
A counter that only counts up is a vector with one entry per replica and a per-entry maximum for merge; a counter that also counts down is two of them. A register can keep the later write or keep both. A set that only grows is a union; a set that also loses elements can let removal win, or let adds win by tagging every add and having a removal take away only the tags it has seen. Such types can be put side by side and merged part by part, and a map keeps one under every key. These all converge, and each means something different by a clash.
What the approach does not do is keep a rule that spans all the replicas, such as a count that never goes below zero, or a rule that joins two parts; for that, replicas must agree, or hand out rights in advance. It does not decide which meaning of a clash is right, and it is not the same as keeping one order of all the updates: it permits results no single order would give, and it is available where one order would need agreement.
The papers have four authors, Marc Shapiro, Nuno Preguiça, Carlos Baquero and Marek Zawirski, and all are credited here. No one in the book is named: the libraries go by number.
| the libraries, each with its own copy of the compendium | Replicas, one at each process. Short paper §2; report §2. |
| an entry, made of parts | An object whose payload is made of CRDT components; CRDT types can be composed. Short paper, abstract; report §2.1, spec. 7. |
| the larger tally stands, for the whole entry | The last-writer-wins rule over a whole object, as in Johnson and Thomas' database of registers. Short paper, related work. |
| the number of sightings, read from any board | The query, value, which any replica can answer from its own state. Short paper §2.1; report spec. 6. |
| libraries that have taken in the same changes show the same entry | Strong eventual consistency (SEC): strong convergence. Short paper §2.2. |
| a library changes its copy at once: no waiting, no vote, nothing undone | No synchronisation, no consensus, no roll-back; up to n − 1 crashes tolerated. Short paper §1, §3.1. |
| a column for each library, written only by its own library | A vector of integers with one entry per replica. Short paper §4.1; report spec. 6. |
| taking the larger pile in each column | Merge as least upper bound: the per-entry maximum. Short paper §2.3, §4.1. |
| any order, any grouping, as often as you like | The join is commutative, associative and idempotent. Short paper §2.3. |
| adding the piles counts a pebble twice | Merge by addition is not idempotent, so not a CvRDT. Report §3.1.2. |
| the board way | State-based replication: a CvRDT. Short paper §2.3, Theorem 1. |
| the slip way; exactly once, in order of dependence | Op-based replication: a CmRDT, with reliable causal broadcast. Short paper §2.4, Theorem 2. |
| each way is a disguise of the other | CvRDTs and CmRDTs emulate each other. Short paper §3.2, Theorems 3 and 4. |
| white pebbles for sightings recorded, black for sightings struck; the count is white less black | PN-Counter: two G-Counters. Report §3.1.3, spec. 7. |
| two libraries striking the one sighting, and the count at −1 | A global invariant cannot be kept without synchronisation: two replicas at value 1 decrement concurrently and converge to −1. Report §3.1.4. |
| a library strikes only sightings it recorded itself | A local invariant implying the global one, P[g] − N[g] ≥ 0; rights reserved in advance, as in escrow. Report §3.1.4. |
| the later account stands by its tally | LWW-Register. Report §3.2.1, specs. 8, 9. |
| both accounts kept, each with what its writer had read: “some say … others say …” | MV-Register, with version vectors. Report §3.2.2, spec. 10. |
| references only ever added | G-Set: union. Report §3.3.1, spec. 11. |
| the struck-off list: once struck, never restored | 2P-Set, with a tombstone set. Report §3.3.2, spec. 12. |
| a tag for every writing; a strike removes the tags it has seen | OR-Set (observed-remove, add wins). Report §3.3.5, spec. 15. |
| a reference carrying a tally; a reference carrying a count | LWW-element-Set; PN-Set. Report §3.3.3, §3.3.4. |
| headings with a tag for every writing into the entry; a withdrawn heading that was written into stands | A map on an OR-Set of keys, as the report's OR-Cart. Report §5, spec. 21. |
| a reference to a withdrawn heading | An invariant across objects; objects are independent and transactions are not considered. Report §2.1. |
| two libraries each adding one reference and striking the other's, ending with both | SEC is incomparable with sequential consistency. Short paper §3.3. |
| throwing away old strikes needs every library heard from | Distributed garbage collection of the log or tombstones (Wuu and Bernstein). Short paper §4.2. |
| a web of cross-references, and a text edited line by line, left to the paper | Graph and sequence CRDTs. Short paper §5; report §3.4, §3.5. |