-1

I face this problem with software development quite often, but I don't really know the name of this issue. It sounds quite common, though.

  • Two nodes (a computer and a mobile phone, for example) share a common sqlite database (as a file).
  • At minute 00:00, both had the same entries and life was perfect.
  • At minute 01:00, the 2nd node edited a row in its local copy of the DB
  • At minute 02:00, the 1st node edited the same row in its local copy of the DB
  • At minute 03:00, the 1st node synced with the remote server
    • Now, the remote server's version of the DB has the 1st node's changes
  • At minute 04:00 the 2nd node attempted a sync with the remote server
    • Now, there's a conflict that either the 2nd node's client or the remote server has to deal with

I do realize that CRDTs (like automerge) can solve this issue and programs like git deal with this on constant basis in the name of merge conflicts, but what about this case? Automerge is restricted to JSON structures and git is restricted to git.

In a personal note-taking project, I solved this issue by just having a git repo that my computer and phone share, and I manually solve merge conflicts, but is there a general 'non-interactive' solution to this that extends to databases (agnostic of the DBRMS like sqlite).

Also, what's the name of this topic in the world of software engineering?

Many thanks in advance

1
  • Note that automerge's strategy for dealing with conflicting changes is to arbitrarily but consistently pick one resolution. In your case, either the node1 or node2 data would be chosen with no way to influence the outcome. CRDTs are not magic unless you remove conflicts by definition (like automerge does) or by severely restricting which operations are permitted on the datamodel (e.g. only adding/subtracting a counter but never assigning it, since += and -= operators can be reordered freely).
    – amon
    Oct 23 at 21:50
0

I'm not aware of any other name than "merge conflicts." There are many different strategies, and which one you use is usually application dependent. If you search for youtube talks on CRDTs, there are some good talks that address it. You can:

  • Insert both rows.
  • Arbitrarily pick one to win.
  • Designate a "master" version that will win.
  • Use a timestamp and let the newest one win.
  • If it's a number, you can let the highest one win.
  • Prompt the user to manually resolve the conflict.

There's no one method that works in all applications.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.