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.
![../_images/fast_forward.png](../_images/fast_forward.png)
In the illustration above:
Device A (green) produces a new record,
r
. It gets assigned record versionA1
and history[ A1 ]
.Next, Device A modifies
r
. The record version changes toA2
and 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
r
and sets the record version toB1
. The history ofr
is 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
B1
can 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.
![../_images/merge_conflict.png](../_images/merge_conflict.png)
In the illustration above:
As above, Device A (green) produces a new record
r
with versionA1
and 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 toB1
and the history[ B1, A1 ]
.Device A modifies its own copy of record
r
and saves it asA2
with 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.