I’ve been working with mobile devices for a long time, and inevitably the most painful piece of the development process is getting data to be consistent across all replicas.
For years, I’ve been trying to find a consistent means of taking care of this in a way which is OS and repository agnostic for all replicas. It isn’t 100% clear to me why this isn’t a solved problem, but I have a feeling there are several contributing factors:
- Internecine conflict between all relevant parties.
- Rapidly changing means and standards for data storage and transmission.
- Figuring out causal relationships between data on different replicas is really, really difficult.
When dealing with data, browser based apps are still likely to be a problem with large data sets and long periods without connectivity, but it might be worth exploring the possibilities again.
To this end, I’ve been looking at solving the causal problem with Interval Tree Clocks (ITCs) lately. They are interesting in the way that licking battery terminals is interesting. They are painfully tedious, but if you can stick with it, you may eventually power a solution (or be brain damaged).
For a long time, I think the standard way to handle the problem of causal relationships has been vector clocks, but they have well documented limitations around space usage which do not apply to Interval Tree Clocks.
Also, you can make pretty diagrams with ITCs.
You can check the code out here.
If you prefer Java, Erlang or c, there is a repository from the original designers of the algorithm here. A word of warning: if you try to use that repository to follow along with my code, it will be very difficult. Conceptually, the code is somewhat similar to what I have written, but my implementation is almost entirely different.