rystsov / caspaxos

CASPaxos: Replicated State Machines without logs
92 stars 11 forks source link

Question about the consistency? #9

Closed bitraft closed 4 years ago

bitraft commented 4 years ago

Assume the following operational procedures:

Step 1: the client send function(value + 1), but only one accepter get the confirmations message. (others accepter never get the message because network problem)

Step 2: the client send function(value + 2), Client get +2 result if step 1 accepter is offline, get value +3 if not offline, Is this correct ?

If so, the consistency value is depend on the network status ?

rystsov commented 4 years ago

Let the acceptors have the following state in the beginning (promised ballot, (accepted ballot, accepted value)): [(0,(0,0)), (0,(0,0)), (0,(0,0))].

When a client sends an increment request (x -> x+1) and it gets applied only on one acceptor because of the network issues - the acceptor's state may end up with: [(1,(0,0)), (0,(0,0)), (1,(1,1))].

It worth to notice that:

  1. the true state is unknown because a proposer never got quorum and the request timeouted so even the client doesn't know the outcome (may passed or may not passed)

  2. accept phase starts strictly after the prepare phase so at least quorum must have promised ballot number 1

Let another client issue the second request (x -> x+2).

Case A. Imagine 3rd acceptor is still offline then after the successful execution the state is: [(2,(2,2)), (2,(2,2)), (1,(1,1))]

Case B. imaging the 3rd acceptor comes back online but 2nd goes offline then the state will be: [(2,(2,3)), (0,(0,0)), (2,(2,3))]

It's true that in some cases the outcome of an operation depends on the state of the network. But it never leads to a contradiction because in such cases the true state is unknown and there is nobody who may witness the violation. Also if it's the case A and the acceptor is still offline it's guaranteed that freshly accepted values has higher ballot number so its value is overwritten and won't affect further rounds.