“Stateless” sync using version vectors
archagon.net
archagon.net
This actually works perfectly fine for my needs because a single user is not likely to be modifying two tasks across two devices at the same time. It may actually work for this project as well (since it's single user). You can check out the code here: https://github.com/allenu/slouchdb
Depending on your use case property by property conflict resolution works great but it can also go horrible wrong with some data. Do you have timestamps on each property?
I would be curious about another scenario: what about several devices generating a new password for a website? Or instead - creating a note with the same name?
The one that is going to be saved is the last one - that is true. But it implies there's some transparent data loss in the background (you could still get those from the log, of course).
How do you deal with those "soft" conflicts in the UI? Is there any learning curve for the user to accept that any changes could be rolled back? How do you display that so that the user wouldn't assume the data was lost?
It would help to have a user guided merge feature that can be manually triggered by combining items (not just on conflict)
You're right that it gets even more tricky if you are doing key=>value pairs and are expecting that the key is something that may not be unique across devices (i.e. two devices using the same website domain as they key would lead to a conflict).
Normally this might be annoying but with merge as a first class citizen its easy to add a "merge these items" feature. Not only is there no hidden data loss, but it also adds the nifty feature of being able to merge totally unique item.
Conflict resolution falls apart if there are multiple users on multiple devices, but my assumption with my solution is that it's only to be used by a single user across multiple devices.
What happens if two different devices try to make updates within the window of your timesync error? Who wins then? Because they both think that they're the latest and therefore their write should win.
So in that regard, the above description is more elegant, yet somewhat irrelevant to text/rich-text merging that OT does.
You can trivially extend the above description to handle multi-user functionality by:
- Putting an upper bound on the time skew to (A) increase resolution of sync while (B) not needing to trust that clock drift is non-trivial.
- Using a state machine to resolve updates outside the bounds of the current machine's current context (including any erroneous clock drift).
- Running a P2P NTP algorithm to reduce clock drift where possible, without needing intermediary servers.
- Deterministically fallback to a naive algorithm, like lexical sort, if & only if updates collide on the same vector on the same timestamp. This is important as a lot of CRDTs don't handle conflicts that happen on vector collisions.
We've learned a lot implementing these things in production (it runs on Internet Archive, plus a lot of "dApps" that are doing terabytes of daily traffic) with our system - a good overview is a "comic strip explainer" I did that explains more thoroughly the reasoning behind thes various choices ( http://gun.js.org/distributed/matters.html ).
Why would anyone take the gross simplification that is the orbital picture and then have a problem with particles physically moving between the levels? Why invent this silly notion of "teleportation", if you want quantum mechanics to get spooky just draw the proper probability clouds for Dirac's sake!
What does this have to do with anything we're discussing? Did you accidentally post your reply in the wrong tab?