Conflict-Free Replicated Data Types
Conflict-free replicated data types obtain convergence from algebraic laws. A counter shows why componentwise maximum can tolerate duplicate messages without losing increments.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 3
- Reading time
- 1 min
In this article3 chapters
Merge as a least upper bound
For a state-based CRDT, order states by the information they contain. Local updates should be inflationary, and merging takes the join. Commutativity allows different delivery orders, associativity allows regrouping, and idempotence handles repeated delivery. Once two replicas incorporate the same updates, they have the same abstract state under the strong convergence condition. Eventual delivery and the update discipline are still assumptions.
A join-semilattice makes independently ordered merges converge on the same information. Anti-entropy reconciliation supplies a separate way for replicas to discover which information they still need to exchange.
The counter must remember where increments originate
Give each replica its own component, incremented only by that replica. Merge \(x\) and \(y\) by
\[ (x\sqcup y)_i=\max(x_i,y_i),\qquad \operatorname{value}(x)=\sum_i x_i. \]
For example, states \((3,1)\) and \((2,4)\) merge to \((3,4)\), representing seven increments. Taking the maximum of the two total values instead would miss increments. Adding both totals would double-count increments already received by both replicas. The component structure is what makes the merge safe.
Remove is a semantic decision
A set that supports removal must distinguish an addition already seen by a remover from a concurrent unseen addition. An observed-remove design associates additions with unique identifiers and records which ones were removed. Collecting metadata safely can require knowledge about replica progress. Operation-based CRDTs may impose causal delivery and ask commuting behavior only of concurrent operations. See causal storage, logical clocks, and gossip protocols for mechanisms supporting these assumptions.[1]