A revision to handle commit_merge state (B0, Φ).
Merge model with synchronization.
Pre-conditions: Φ→(A0, B0) Aligned region A and B on nodes. A synchronous point between executions of raft group A and B.
(1)(A0, B0)→(A1, B0) Stop KV on peerA.
(2)(A1, B0)→(A1, B1) Enlarge region B.
(3)(A1, B1)→(A2, B2) Remove peerA or peerB in case.
Post-conditions: region B.
Implement steps.
Φ.
(0)
Align peerA and peerB on the nodes. This is a point for synchronizing region A and B.
(A0, B0).
(1) peerA.prepare_merging:
if A0 and Φ, nop.
if A0 and B0, set peerA State::Merging.
if A0 and B1, nop.
if A0 and B2, nop.
(A1, B0).
call extended_RaftA.
(2) extended_RaftA:
if A1 and Φ and leader, call raftA.rollback_merge.
if A1 and B0 and leader, call raftB.commit_merge.
(3) peerB.commit_merge:
if B0 and Φ, nop.
if B0 and A0, peerA.catchup_logs.
if B0 and A1, set region B.
if B0 and A2, nop.
(A1, B1).
call extended_RaftB.
(4) extended_RaftB:
if B1 and Φ, remove peerB.
if B1 and A1, remove peerA.
(A2, B2).