5

So, I've got a google docs type feature in my app which can be edited by multiple users concurrently. Diff-match-patch works fine for me when only one user updates the doc.

But it generates wrong data when let's say the doc is already updated by user1 and it's not delivered to user2(due to socket error or network error).

For example - 'Stack overflow is 55666.' is my doc, which is being edited by multiple users. Now, user1 changes it to 'Stack overflow is 6.'

and calculates diff and sends it to the server but before that user2 has already changed it to something else, say 'Stack overflow is 25552.'. Now when the patch(from user1) is applied, it generated wrong result which could be 'Stack overflow is 252.'

So how can I manage it to achieve concurrent update? I can use Socket so that if someone else changes, I send that change to other users so that they can have the latest updated data but if the change is a lot the UX can be bad as other users may see a random change in view.

Rahul
  • 863
  • 6
  • 23
  • 2
    What exactly is the problem you are trying to solve? See [How to ask] (https://stackoverflow.com/help/how-to-ask) page, you should tell what you get and what you would like to get. Otherwise the question seems simply too broad. – Frax May 21 '18 at 08:33
  • Modified the question, please take a look. – Rahul Jul 06 '18 at 04:14
  • did you solve? because i'm looking at a diff/patch algorithm and when i try to apply multiple patches to the same base concurrently the output is highly dependent on how the diffs are generated. that is to say, there is not a single set of changes that can be applied to a string to get to another string, and which set of changes is used changes the output when there are multiple diffs applied simultaneously – Michael Aug 20 '20 at 01:48
  • No Michael. I had to take a different approach to resolve this. You have to consider rows & columns and etc to achieve concurrent updates. My solution was motivated by https://en.wikipedia.org/wiki/Operational_transformation – Rahul Aug 20 '20 at 14:00

0 Answers0