Distributed System (5)

Chandy-Lamport Algorithm

(Snapshot should not interfere with normal application actions, and it should not require application to stop sending messages.)

First, initiator PiP_i :

  • records its own state
  • creates a special marker message.
  • for j=1n,jij=1\ldots n, j\ne i
    • PiP_i sends a marker message on outgoing channel cijc_{ij}
    • start recording cjic_{ji}

For other process PiP_i receiving a marked message from channel ckic_{ki} ,

  • if it is the first time PiP_i see marked message
    • PiP_i records its own state
    • marks the state of ckic_{ki} as “empty”
    • for j=1n,jij=1\ldots n, j\ne i
      • PiP_i sends a marked message over cijc_{ij}
      • if jkj\ne k
        • start recording cjic_{ji}
  • else
    • stop recording ckic_{ki} (the state of channel contains all messages during recording)

<video controls src…/img/post/distributed-system-5-output.mp4" title=“Chandy-Lamport Algorithm” width=“60%”>

Any run of the Chandy-Lamport Global Snapshot algorithm creates a consistent cut.

Proof.

  • for every pair of causal messages mimjm_i \to m_j corresponding to process Pi,PjP_i, P_j , if mjm_j is in the cut, then mim_i is also in the cut.
  • prove by contracdition: if not, mim_i was sent before PjP_j sending the marked message but arrive before it, then the cannel is not FIFO.

linearization

  • A run is a total ordering of events in the global history HH that is consistent with each hih_i ’s ordering.
    • A linearization is a run consistent with happens-before
    ( \to ) relation in HH .

  • Run: <e10,e11,e12,e13,e20,e21e22>< e_1^0, e_1^1, e_1^2, e_1^3 , e_2^0, e_2^1 e_2^2 > (keeping the order within each process suffies)
  • Linearization: <e10,e11,e12,e20,e21e22,e13>< e_1^0, e_1^1, e_1^2, e_2^0, e_2^1 e_2^2 , e_1^3 >

Execution Lattice

Each path represents a linearization.

An lattice of


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