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.
Align peerA and peerB on the nodes. This is a point for synchronizing region A and B.
if A0 and Φ, nop.
if A0 and B0, set peerA State::Merging.
if A0 and B1, nop.
if A0 and B2, nop.
if A1 and Φ and leader, call raftA.rollback_merge.
if A1 and B0 and leader, call raftB.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.
if B1 and Φ, remove peerB.
if B1 and A1, remove peerA.