Distributed Systems: Global States
Distributed Systems: Global States
Distributed Systems: Global States
Global States
Detecting global properties
We want to find out whether a particular property is true of a
distributed system as it executes.
We will see three examples:
Distributed garbage collection: if there are no longer any
reference to objects anywhere in the distributed system, the
memory taken up by the objects should be reclaimed.
p1 p2
object
reference
message
a. Garbage collection garbage object
p1 p2
wait-for
b. Deadlock wait-for
p1 p2
activate
c. Termination passive passive
Global States and consistent cuts
The question is: can we assemble the global state of the system
from local states recorded at different real times?
m1 m2
Physical
p2
0 1 2 time
e2 e2 e2
A cut of the system’s execution is a subset of its global history that is a union
of prefixes of process histories.
m1 m2
Physical
p2
0 1 2 time
e2 e2 e2
• Each process records its own state and also for each
incoming channel a set of messages sent to it.
p1 c2 p2
c1
Two processes connected by two unidirectional channels, c1 and c2. The two
processes trade in ‘widgets’. Process p1 sends orders for widgets over c2 to p2,
enclosing payment at the rate of $10 per widget. Some time later, process p2
sends widgets along channel c1 to p1.
Process p2 already received an order for five widgets, which it will shortly
dispatch to p1.
The execution of the processes
1. Global state S 0
<$1000, 0> p1 c2 (empty) p2 <$50, 2000>
c1 (empty)
(M = marker message)
1. P1 records its state in S0. Following the marker sending rule, it will send a
marker over c2 to p2 before it sends the next order (10, $100). 2. Before p2
receives the marker, it sends five widgets to p1 over c1. 3. Now P1 receives five
widgets and P2 receives marker. P2 will record it state S2 and record c2 as
empty. Following the sending rule, p2 sends a marker to p1. 4. P1 receives the
marker, P1 records the state of c1 as five widget that it received after it first
recorded its state.
Chandy-Lamport Algorithm Proof
Theorem: The Chandy-Lamport Algorithm terminates
– Proof:
•Assumption: a process receiving a marker message will
record its state and send marker messages via each
outgoing channel in finite period of time.
•If there is a communication path from P_i to P_k, then P_k
will record its state a finite period of time after P_i
•Since the communication graph is strongly connected, all
process in the graph will have terminated recording their
state and the state of incoming channels a finite time after
some process initiated snapshot taking.
Chandy-Lamport Algorithm Proof
Theorem: Snapshots taken by the Chandy-Lamport Algorithm correspond
to consistent global states
Proof:
Let e_i and e_k be events at P_i and P_k, and let e_i → e_k.
Then, if e_k is in the cut, so is e_i.
That means, if e_k occurred before P_k recorded its state, then e_i must
have
occurred before P_i recorded its state
k=i: obvious.
k≠i: assume P_i recorded its state before e_i occurred
- as k≠i there must be a finite sequence of messages
m_1,..., m_n that induced e_i → e_k
- then, before any of the m_1,..., m_n had arrived, a
marker
must have arrived at P_k , and P_k must have recorded
it’s
state before e_k occurred, hence a contradiction to the
above assumption
Summary
• Global state