title Replication - Split Brain Detected

participant Client1 
participant Instance1
participant Global Ref-DB
participant Instance2
participant Client2

state over Client1, Client2, Instance1, Instance2: W0
state over Client1 : W0 -> W1
Client1 -> +Instance1: Push W1
Instance1 -> +Global Ref-DB: CAS if state == W0 set state W0 -> W1
state over Global Ref-DB : W0 -> W1
Global Ref-DB -> -Instance1 : ACK
state over Instance1 : W0 -> W1
Instance1 -> -Client1: Ack W1

state over Instance1 : Crash

state over Client2 : W0 -> W2
Client2 -> +Instance2: Push W2

Instance2 -> +Global Ref-DB: CAS if state == W0 set state W0 -> W2
Global Ref-DB -> -Instance2 : NACK

Instance2 -> -Client2 : Push failed -- RO Mode

state over Instance1:  Restart

Instance1->Instance2: Replicate W1 

state over Instance2 : W0 -> W1

Client2 -> +Instance2: Pull W1
Instance2 -> Client2 : Missing W1
Client2 -> Instance2: Pull W1
state over Client2 : W0 -> W1 -> W2
Client2 -> Instance2: Push W2
Instance2 -> +Global Ref-DB: CAS if state == W1 set state W1 -> W2
state over Global Ref-DB: W0 -> W1 -> W2
Global Ref-DB -> -Instance2 : ACK
state over Instance2: W0 -> W1 -> W2 
Instance2 -> -Client2 : ACK 


