11 ms·
> If the state was concurrently changed on different devices, Automerge automatically merges the changes together cleanly, so that everybody ends up in the same
by bringtheaction 9y ago
> If the state was concurrently changed on different devices, Automerge automatically merges the changes together cleanly, so that everybody ends up in the same state, and no changes are lost.
> Different from git: no merge conflicts to resolve!
This is impossible unless there are significant restrictions on what kind of operations are possible.
If I have a bag of 15 apples, and I take 10 of those apples at the same time as somebody else takes more than five apples then we have a merge conflict right there because we can't end up with a negative amount of apples in the bag.
- kba 9y agoThen there'd be a negative amount of apples. It's not impossible if you disregard context. There is nothing new about doing things like this, OT and CRDT have existed for ages. Check out ShareDB (https://github.com/share/sharedb https://github.com/share/sharedb) or Webstrates (https://webstrates.net/ https://webstrates.net/) (based on ShareDB). In Webstrates, we don't have merge conflicts that need to be resolved and there are never any practical synchronization issues. The server orders the operation and if you try to delete something that's already been deleted, then we just ignore your operation. Also quite courageous to say something is impossible when you have the code that does it right in front of you. ;-)
- KirinDave 9y agoI think when we say "impossible" we mean "well sure any old thing is possible but there are hard limits on what's consistent and sane." I will go read the docs in more detail but what you've just describes sounds pretty awful. Perhaps it's more just you being glib about non-cooperative actors in an environment that expects cooperatuon, but an "available balance" abstractions are a pretty reasonable thing to ask for, if only to encode natural numbers.
- kba 9y agoI'm not one to dictate how technologies like these are to be used, but all I can say is that in the almost two years I've been working on Webstrates – a collaborative system using a very similar technology – this has not been an issue. But surely, if you allow malicious actors to modify your document, then that's your problem right there.
- pvh 9y agoShareDB looks quite interesting. We wanted similar capabilities but without a central authority, thus automerge was born.
- kba 9y agoWe've been wanting to try a CRDT-based implementation with Webstrates for some time, but haven't found a suitable implementation, so this looks very promising! Any particular reason why you choose CRDT over OT?
- pvh 9y agoI'm told OT gets very complicated, and I hoped a good CRDT would be general-purpose enough to cover a variety of applications and domains. Also, I like not needing a central server to coordinate action. Would love to compare notes -- feel free to reach out to me on twitter at the same nick.
- imtringued 9y agoIt's still impossible in the general case. You merely proved him right. Limiting yourself to OTs and CRDTs is a signficant restriction.
- kba 9y agoWhy is that a restriction? You can make any changes to the JSON you wish, you just have to use their API.
- kaoD 9y agoIt's right there in the README: > The only case Automerge cannot handle automatically, because there is no well-defined resolution, is when users concurrently update the same property in the same object (or, similarly, the same index in the same list). In this case, Automerge arbitrarily picks one of the concurrently written values as the "winner": https://github.com/automerge/automerge#conflicting-changes https://github.com/automerge/automerge#conflicting-changes
- sli 9y agoMerge conflicts are handled transparently and seemingly indeterminately? Yikes.
- kba 9y agoThis isn't for a banking system, this is for building collaborative apps. If you press "A" and your friend press "B" into a Google Docs document at the same time, you also don't know if the document is going to read "AB" or "BA". In practice, this is not an issue.
- nolok 9y agoWell, so much for "no changes are lost", instead it should be "one of the change is lost, and you can't know which one until it's done ! Suprise !!!"
- amelius 9y agoAnother problem is this. Let's say there is a counter that is at value 100. I increment the counter. Simultaneously another user increments the counter, so the stable value should be 102. However, a operation-agnostic "merging" approach like described here can never catch that, and sets the final value to 101.
- insomniacity 9y agoAs I understand it, CRDTs don’t work on atomic types you might use in normal code - they work on larger structures where the problem has been solved. Wikipedia has some examples: https://en.m.wikipedia.org/wiki/Conflict-free_replicated_data_type https://en.m.wikipedia.org/wiki/Conflict-free_replicated_dat...
- kba 9y agoMy experience is with OT, so I can't speak for CRDT, but I can imagine it's similar. With OT, you send a na[1] (number add) operation, so this would work fine. Indeed, if you treat the number as a string, then you have a problem. [1]: https://github.com/ottypes/json0#summary-of-operations https://github.com/ottypes/json0#summary-of-operations
- taeric 9y agoThis doesn't compose with all operations. One users adds and another user multiplies, for example. That is to say, not all operations are associative. I bet you can run really far with this general idea. But there is no panacea.
- kba 9y agoYou're absolutely right, but I'd also never suggest a collaborative system for anything critical. As I've said earlier in this thread: If you're in a Google Docs document with a buddy and you write "A" and he writes "B" at the same time, you also don't know whether that'll show up as "AB" or "BA". In practice, this isn't an issue.
- 9y ago
- amelius 9y agoYet another problem is access-control: what if a user is allowed to access only part of the data-structure? And what if you'd want to encode access rules in the data-structure itself?