There are various possibilities for implementing parallel replica changes depending on the scenario topology and various compromises.
Using a central server
The most common scenario is a central server with which all clients must communicate.
The server can track how each participant’s document looks. Then A and B send diff with their changes to the server. The server will then apply the changes to the corresponding tracking documents. He will then perform a three-way merger and apply the changes to the main document. He will then send the difference between the main document and the tracking documents to the relevant customers. This is called differential synchronization .
Another approach is called operation conversion (al), which is similar to rebooting in traditional version control systems. This does not require a central server, but at the same time you have it much easier if you have more than two participants (see OT FAQ ). The bottom line is that you are changing the changes in one edit, so editing assumes that changes to another editing have already occurred. For example. A converts B edit insert(3, hello) to its edit insert(0, abc) with the result insert(6, hello) .
The difference between rebasing and OT is that rebasing does not guarantee consistency if you apply the changes in different orders (for example, if B had to reinstall A edit against them the other way around, this could lead to diverging states of the document). OT's promise, on the other hand, is to allow any order if you make the right transforms.
No central server
There are OT algorithms that can work with peer-to-peer scenarios (with a compromise of increased implementation complexity at the control level and increased memory usage). Instead of a simple timestamp, a version vector can be used to track the state on which the change is based. Then (depending on the ability of your OT algorithm, in particular, conversion of property 2), incoming changes can be converted in accordance with the order in which they are received, or the version vector can be used to superimpose a partial order on editing - this should be the case history " overwritten, "destroying and transforming the changes so that they correspond to the order imposed by the version vectors.
Finally, there is a group of algorithms called CRDT, WOOT, treedoc, and logoot that try to solve the problem with specially designed data types that allow commutation of operations, so the order in which they are applied does not matter (this is similar to your idea of an ID for each character). The trade-offs here are memory consumption and overhead when building an operation.
Marcel klehr
source share