CRDT and SQLite: Local-First Value Synchronization

(marcobambini.substack.com)

48 points | by marcobambini 4 days ago

3 comments

  • philsnow 2 hours ago
    We shouldn't be surprised because the writer works with both sqlite and AI but

    > Here’s a polished section you can insert into your article (it fits naturally after the Sync Phase section):

  • briandw 3 hours ago
    For a primer on CRDTs, Martin Kleppmann has a number of good videos: https://www.youtube.com/watch?v=x7drE24geUw
  • withinboredom 3 hours ago
    This works assuming everyone has the same clock or performs changes causually distant from each other. It fails to work if, say, 1000 people all make a change around the same time. This also applies to lamport timestamps.
    • p1necone 1 hour ago
      If a thousand people all made a change at the same time in a totally deterministic, always online system a single one of those writes would arbitrarily win in exactly the same way.

      In practice "1000 people edit same thing at same time" is not a problem that needs to be solved via software, the users are just doing silly things and getting silly results.

      • withinboredom 1 hour ago
        If it isn’t handled correctly, you’ll eventually end up with parallel histories on different devices. Even if it isn’t 1000 people, people will share documents with entire classrooms, offices, etc., which increases the probability of this situation tremendously.
        • ncruces 54 minutes ago
          CRDTs only care that the end result is eventually the same.

          It doesn't need to make sense, or be the most recent change, only that given the same inputs, everyone independently agrees on the same output.

          • withinboredom 42 minutes ago
            We are saying the same thing. I was pointing out that the article missed one of the hardest parts of actually implementing this, where your algorithm architecture can totally fuck you over if you didn’t plan for it. I just think it’s interesting that they missed pointing it out. Either they got it right on the first try or they haven’t realized the issue with the schema they’re proposing.
    • marcobambini 2 hours ago
      The algorithm has a way to resolve conflicts even if, by any chance, the Lamport clock has the same value in all peers
      • withinboredom 2 hours ago
        Yeah, but the fact that they didn’t even mention it in their post is why I brought it up.