Discussion about this post

User's avatar
7ie7an's avatar

It seems like the HLC example needs communication to sychronize the clock and/or the message counter. At least for me it is not clear how this "Survives weeks of offline use without data loss". Maybe there is a missunderstanding in my perception but doesn't this contradict the "Quick Example"?

B's HLC Time cannot be corrected (or the counter incremented) if A, B or any other event recording participant is offline.

Expand full comment
Jacob Wright's avatar

A couple thoughts:

1. with HLC, what if one device is way off, like 1 year in the future? Does that mean all devices sync to use that furthest-future time and then just start using the counter only? How do they determine who will win if they have the same timestamp and counter? You might need a client ID to sort them by, or another timestamp algorithm.

2. your example with modifying balance shows how weak LWW is. If 2 clients change a balance by +20 and -20, you would *want* the result to be a net zero change. The most naive approach is to let the server decide the value by who arrived last. Your approach by adding a timestamp is slightly better. For a balance, you'd want a PN-Counter that captures increments and decrements so they can merge together.

I'd be interested how you can store different types of CRDTs in SQLite.

Expand full comment
4 more comments...

No posts