Concurrency in Collaborative Editing
Let’s explore different methods of conflict resolution in concurrent collaboration on a document.
Introduction
We’ve discussed the design for a collaborative document editing service, but we haven’t addressed how we’ll deal with concurrent changes in the document by different users. However, before discussing concurrency issues, we need to understand the collaborative text editor.
What is a document editor?
A document is a composition of characters in a specific order. Each character has a value and a positional index. The character can be a letter, a number, an enter (↵), or a space. An index represents the character’s position within the ordered list of characters.
The job of the text or document editor is to perform operations like insert()
, delete()
, edit()
, and more on the characters within the document. A depiction of a document and how the editor will perform these operations is below.
Concurrency issues
Collaboration on the same document by different users can lead to concurrency issues. Conflicts may arise whenever multiple users edit the same portion of a document. Since users have a local copy of the document, the final status of the document may be different at the server from what the users see at their end. After the server pushes the updated version, users discover the unexpected outcome.
Example 1
Let’s consider a scenario where two users want to add some characters at the same positional index. Below, we’ve ...