You might not need a CRDT

# · 🔥 369 · 💬 132 · one year ago · driftingin.space · paulgb · 📷
Changes made on one copy need to be reflected by the others, as quickly as possible. If you then add an item 'get groceries' in the third position, your replica emits an event meaning "Insert 'get groceries' before item #3". This works fine as long as enough time passes for each of us to receive the others' changes before making our own change. Each replica might receive and apply the changes in a different order. In the to-do example, it's possible that the server sees your "Add Clean kitchen" change before my "Check item #1" change, and incorrectly marks the new item as checked. A typical solution in this case is to generate a random UUID for each item when it is created, so that my change is instead represented as "Check item 8e503f34", and is applied correctly regardless of where the item I intend to check is in the list by the time my change is applied on a replica. State machine replication is not a silver bullet; we still need to be thoughtful about how change operations apply when the underlying data has changed. Even if each replica ensures that changes made to it don't introduce a cycle, two innocent changes made concurrently on two replicas could combine to break the invariant.
You might not need a CRDT



Send Feedback | WebAssembly Version (beta)