The Chandy–Lamport algorithm is a snapshot algorithm that is used in distributed systems for recording a consistent global state of an asynchronous system.
Interesting thing about Chandy-Lamport algorithm is that
total order anomaly.FIFO order. 
As mentioned, there is no cooridnator that ochestrates snapshotting process. It's just any random coordinator that begins the process and let's call this initiator process. It does:
When a process Pi gets a marker message on channel Cki(channel from Pk to Pi) :
Pi has seen:Pi records its statePi marks channel Cki as emptyPi sends a marker out on every outgoing channel(Cij)Pi starts recoding incoming messages on all its incoming channels except Cki which was the one on which the first marker came in.(TL;DR;record your start & start recoding incoming messages)
What counds as seeing? If you have done anything at all, you've seen this.
Pi stops recoding recoding on Cki and sets the channel, Cki's final state as the sequence of all the incoming messages that arrived on Cki since recoding began. What if the marker message arrives before C in the following?

In this case, s2 gets smaller, capturing only B and not C. And marker message would sent back like this:

Remember that before doing anything else like sending C, P2 has to send marker messages out on all of its outgoing channels. If cross over happens between marker message going back to p1 and C as follows, P1 will include D in its snapshot.

Let's say we have the following processes and events.





Now, P1 gets P2 which was waiting for the marker message to come in to finish up the snapshot. And from the time P1 sent the marker message, P1 received D from P2 so it's included in snapshot.
On P3, it hasn't received any message through C23 so when it receives marker message from P2, it just marks the channel as empty.
Therefore the end result will be:

It knows its done when it has recorded its own state and the state of all of its incoming channel.
This is a problem that gets solved EXTERNALLY to the Chandy-Lamport algorithm. What the algorithm does is establish a way for every process to take its own individual snapshot.
They would, actually. The only reason it didn't get recorded was because when, for example, P1 decided to take snapshot of its own state, C hadn't happened yet. This is important to make sure that every process has the snapshot of causally-related snapshot.
There are a lot of assumptions involved:
In the next post, I'll talk more about this assumptions this algorithm makes.