个人网站www.pixysoft.net设计系列: 目标数据库同步的重构2
同步算法改进
Use Case 1 complex Situation
A insert 100
la100-0
A upload 100
la100-1
w100-1/1
B download
la100-1
w100-1/1
lb100-1
A delete 99
la1-1 la99-1[delete]
w100-1/1
lb1-1 lb99-1
A upload
la1-2
w1-1/2
lb1-1 lb99-1
A insert 50
la1-2 la50-0
w1-1/2
lb1-1 lb99-1
A upload,
la1-3 la50-3
w1-1/3 w50-3/3
lb1-1 lb99-1
A update(from insert 50) 1
la1-3 la49-3 la1-3
w1-1/3 w50-3/3
lb1-1 lb99-1
A upload
la1-4 la49-4 la1-4
w1-1/4 w49-3/4 w1-4/4
lb1-1 lb99-1
We stop here! and discussion!
One: it is ok!
B download
lb-4 lb99-1 b49-4 b1-4 then clear
lb-4 [none] b49-4 b1-4
------------------------------------------------------------------------------------------------------------------------------------------------------------
Two: conflict
B update 1
la1-4 la49-4 la1-4
w1-1/4 w49-3/4 w1-4/4
lb1-1 lb99-1
B upload
la1-4 la49-4 la1-4
w1-5/5 w49-3/5 w1-4/5
lb1-5 lb99-1[conflict]
A Download
la1-5 la49-5 la1-5 (actually do nothing. just change the global Version)
w1-5/5 w49-3/5 w1-4/5
lb1-5 lb99-1[conflict]