Merging
There are two possible cases for the merging of data: fast-forward merges and conflicts.
Fast-forward merges
A “fast-forward” data merge situation means that there is no conflict to resolve. This can be determined by checking if the current version of a record on the receiving device is already contained in the history of the transmitting device, or vice-versa.
In the illustration above:
Device A (green) produces a new record,
r. It gets assigned record versionA1and history[ A1 ].Next, Device A modifies
r. The record version changes toA2and the history is now[ A2, A1 ].Device B (red) now syncs data with Device A and both the devices have same version and history of record
r.Device B modifies its copy of
rand sets the record version toB1. The history ofris now[ B1, A2, A1 ]on Device B and still[ A2, A1 ]on Device A.When Device A syncs with Device B again (the arrow), there is no conflict and the update
B1can be incorporated directly.
Merge conflicts
A merge conflict means that two devices have made changes to a record, and it is not clear how to reconcile the two change histories.
In the illustration above:
As above, Device A (green) produces a new record
rwith versionA1and history[ A1 ].Device B (red) now syncs data with Device A and both the devices have same copy of record
r.Next, Device B modifies its copy of
r. The record version changes toB1and the history[ B1, A1 ].Device A modifies its own copy of record
rand saves it asA2with history[ A2, A1 ].When Device A syncs data with Device B again (the arrow), there is a conflict because both devices have modified
r.
It is up to the implementing application to determine what the merge conflict resolution strategy is.