Distributed System (6-7)

linearization

  • Liveness: guarantee that something good will happen eventually
  • Safety: guarantee that something bad will never happen.
  • Stable: once true, stays true forever afterwards

Multicast

Basic Multicast (B-Multicast)

  • B-multicast(group gg , message mm ):
    • for each process pp in gg , send (p,m)(p,m) .
  • receive( mm ): B-deliver( mm ) at pp

Reliable Multicast (R-Multicast)

  • Integrity: A correct process pp delivers a message mm at most once.
  • Validity: If a correct process multicasts (sends) message mm , then it will eventually deliver mm to itself. (Liveness)
  • Agreement: If a correct process delivers message mm , then all the other correct processes in group( mm ) will eventually deliver mm .
  • Validity and agreement together ensure overall liveness: if some
    correct process multicasts a message m, then, all correct processes
    deliver m too.

R-multicast is reliable even after the sender crashes.

Implementing R-Multicast

On initialization:

  • Received :=:= \\{\\}

For process pp to R-multicast message mm to group gg

  • B-multicast (g,m)(g,m) , (notice pgp\in g )

On B-deliver (m)(m) at process qq in g=g= group (m)(m)

  • if mm \notin Received
    • Received :=:= Received {m}\cup \{ m \}
    • if pqp \ne q :
      • B-multicast (g,m)(g, m)
    • R-deliver (m)(m)

Ordered Multicast

FIFO ordering

For a process, if it sends m1m_1 before m2m_2 , then all processes recieves m1m_1 before m2m_2 .

Causal ordering

If multicasts m1m2m_1 \to m_2 ( m1m_1 cause m2m_2 , which means a process sends m2m_2 after recieving m1m_1 ), then all processes recieves m1m_1 before m2m_2 .

Causal ordering implies FIFO ordering, because multicasts that sent by a process can be regarded as Causal

Total ordering

For any pair of multicasts m1m_1 , m2m_2 , all processes recieving them recieves them in the same order.

Total Ordering doesn’t imply Causal Ordering

implementing ordered multicast

Implement FIFO multicast

Each process has a sequence vector Pi[1..N]P_i[1..N]

On process PjP_j sending multicast ( gg , mm ):

  • Pj[j]=Pj[j]+1P_j[j] = P_j[j] + 1
  • B-multicast( gg , {m,Pj[j]}\{m, P_j[j]\} )

On process PiP_i recieving multicast {m,S}\{m, S\} from PjP_j :

  • buffer it until S=Pi[j]+1S = P_i[j] + 1 , then
    • deliver (m)(m)
    • Pi[j]+=1P_i[j] += 1

Implement causal order multicast

On process PiP_i sending multicast ( gg , mm ):

  • Pj[j]=Pj[j]+1P_j[j] = P_j[j] + 1
  • B-multicast( gg , {m,Pj[j]}\{m, P_j[j]\} )

On process PiP_i recieving multicast {m,V[1n]}\{m, V[1 \ldots n]\} from PjP_j :

  • buffer it until V[j]=Pi[j]+1V[j] = P_i[j] + 1 and kj:V[k]Pi[k]\forall k\ne j: V[k] \le P_i[k]
    • deliver (m)(m)
    • Pi[j]=V[j]P_i[j] = V[j]

Implement total order multicast

A special process as sequencer.

On process PiP_i sending multicast ( gg , mm ):

  • B-multicast ({g,sequencer},m)(\{g, \text{sequencer}\}, m)

Sequencer:

  • init: S=0S = 0
  • On sequencer recieving multicast {m,S}\{m, S\} from PjP_j :
    • S=S+1S = S + 1
    • B-multicast (g,{"order",m,S})(g, \{ \text{"order"}, m ,S \})

Process PiP_i :

  • init: Si=0S_i = 0
  • On process PiP_i recieving B-deliver (m)(m) from PjP_j :
    • buffer it until

      i. B-deliver (g,{"order",m,S})(g, \{ \text{"order"}, m ,S \}) from sequencer, and

      ii. S==Si+1S == S_i + 1

      , then:
    • deliver (m)(m)
    • Si=Si+1S_i = S_i + 1

ISIS algorithm for total ordering

Sender multicasts message to everyone.

Each message recieved by a process may have:

  • agreed priority
  • proposed priority
  • a marker: undeliverable or not

Each processes PiP_i have

  • largest agreed priority aia_i
  • largest proposed priority pip_i
  • an priority queue of messages order by agreed priority or proposed priority

To send a total order multicast mm to all processes in gg by PiP_i :

  • B-multicast (g,{m,id})(g, \{ m, id\}) where idid is an identifier for mm .
  • take the largest proposed priority collected from all other process as agreed priority aa .
  • ai=max(ai,a)a_i = \max(a_i, a)
  • B-multicast (g,{id,a})(g, \{ id, a\}) (here a can be a:i, i.e. attached with process id to avoid same priority)
  • set aa as the agreed priority of mm
  • mark mm as diliverable
  • update the priority queue
  • if the message mm' at the top of the queue is deliverable:
    • deliver (m)(m')

Upon process PjP_j recieving from PiP_i

  • if received {m,i}\{ m, i\} :
    • take pj:=max(pj,aj)+1p_j := \max(p_j, a_j) + 1 as the new proposed priority.
    • send (Pi,pj)(P_i, p_j)
  • if received {id,a}\{ id, a\} :
    • ai=max(ai,a)a_i = \max(a_i, a)
    • set aa as the agreed priority of mm
    • mark mm as diliverable
    • update the priority queue
    • if the message mm' at the top of the queue is deliverable:
      • deliver (m)(m')

ISIS algorithm takes longer time than sequencer algorithm.
{: .prompt-info }

Proof of ISIS algorithm

two messages: m1m_1 , m2m_2 , two procesess pp , qq .
Assume pp delivers m1m_1 first.

When pp delivers m1m_1 , m2m_2 is either

  • in queue and deliverable.
    • agreed_priority (m1)(m_1) << agreed_priority (m2)(m_2)
  • in queue. not deliverable.
    • agreed_priority (m1)(m_1) << propose_priority (m2)(m_2) \le agreed_priority(m2)(m_2)
  • not in queue.
    • agreed_priority (m2)(m_2) \ge propose_priority (m2)(m_2) >> agreed_priority (m1)(m_1)

Therefore
agreed_priority (m1)(m_1) << agreed_priority (m2)(m_2)

And if qq delivers m2m_2 first, Contradiction.


Distributed System (6-7)
https://yzzzf.xyz/2024/02/05/distributed-system-6-7/
Author
Zifan Ying
Posted on
February 5, 2024
Licensed under