Professional Documents
Culture Documents
Chap 14
Chap 14
2
Clocks, events, and process states [14.2]
• Refine the model in Chapter 2 proprocess interactions
• Consider DS a set P of N processes, pi for i=1, …, N
• Process pi has a state si that (usually) changes over time
• Process pi takes a series of actions, from 3 choices
• Message send
• Message receive
• Operation to transform its state
• Event≡occurrence of a single action that a process caries
out as it executes
• Totally ordered (locally) on a given host,
• History(pi) ≡ hi ≡<ei0, ei1 , ei2 , …> #series of events
• Note: skipping rest of 14.2 … on clocks etc and also 14.3
3
Logical time and logical clocks [14.4]
• (Going to teach through the VR01 slide set for most of this,
then go through the examples here to reinforce)
• Also for vector clocks separate example slides
4
Figure 14.5
Events occurring at three processes
Instructor’s Guide for Coulouris, Dollimore, Kindberg and Blair, Distributed Systems: Concepts and Design Edn. 5
© Pearson Education 2012
Figure 14.6
Lamport timestamps for the events shown in Figure 14.5
Instructor’s Guide for Coulouris, Dollimore, Kindberg and Blair, Distributed Systems: Concepts and Design Edn. 5
© Pearson Education 2012
Vector clocks
• Limitation of Lamport clocks: if L(e) < L(e’) we can’t
conculde that ee’
• Solution: make the LC scalar a vector
• Vi[i]≡number of events that pi has timestamped
• Vi[j] (for i≠j) ≡ #events at pj that may have affected pi and
that pi knows about.
• (Now see slides from the Birman book)
7
Figure 14.7
Vector timestamps for the events shown in Figure 14.5
Instructor’s Guide for Coulouris, Dollimore, Kindberg and Blair, Distributed Systems: Concepts and Design Edn. 5
© Pearson Education 2012
Global states [14.5]
• (See the VR01 slides for best intro to this)
9
Figure 14.9
Cuts
0 1 2 3
e1 e1 e1 e1
p1
m1 m2
p2 Physical
0 1 2 time
e2 e2 e2
Inconsistent cut
Consistent cut
12
Snapshot algorithm
• By Chandy and Lamport [1985]: determine global states
• Goal: record a set of process AND channel states such that it is
consistent (not strongly consistent) for a set of processes pi (i=1, 2,
… N)
• Assumptions
• Neither channels nor processes fail
• Channels are uni-directional and FIFO ordered
• Graph of processes and channels strongly connected (path
between any 2 processes)
• Any process may initiate the snapshot at any time
• Processes don’t need to freeze/lock: continue normal operations
13
Snapshot algorithm (cont.)
• Main ideas
• Terms: incoming channels and outgoing channels for pi
• Each process records its state, and for each incoming channel, set
of messages sent to it
• For each channel, process records channel state: messages that
arrived after its last recorded state and before sender recorded
state
•I.e,. Record state at different times but account for messages transmitted but
not yet received (these are part of the channel state)
• Use distinguished marker messages
•Tell receiver to save state
•Way to determine which messages go in channel state
•To initiate the algorithm, process acts like it received a marker message
14
Figure 14.10
Chandy and Lamport’s ‘snapshot’ algorithm
Instructor’s Guide for Coulouris, Dollimore, Kindberg and Blair, Distributed Systems: Concepts and Design Edn. 5
© Pearson Education 2012
Example of snapshot algorithm
• Two processes, trade in widgets, over two unidirectional
channels
• Process p1 sends orders for widgets to p2 with its payment
($10/widget)
• Process p2 sends widget along other channel
16
Figure 14.11
Two processes and their initial states
Instructor’s Guide for Coulouris, Dollimore, Kindberg and Blair, Distributed Systems: Concepts and Design Edn. 5
© Pearson Education 2012
Figure 14.12
The execution of the processes in Figure 14.11
Note: (1) S0 is when p1 sends marker (3) p1 had previously ordered five widgets; sent before
M received by p2 (5) After above, final recorded state includes five widgets in c1, yet system
Instructor’s Guide for Coulouris, Dollimore, Kindberg and Blair, Distributed Systems: Concepts and Design Edn. 5
did not go throough this state (6) Text explains © Pearsonhow cut is consistent
Education 2012
Distributed debugging [14.6]
• Problem: recording system’s global state to make useful
statements about whether a transitory state occurred in an
actual execution
• Capture trace info and do post hoc analysis
• Chandy and Lamport’s [1985] snapshot algorithm earlier
used to collect states
• Send to monitor process (considered outside the system)
• Algorithm by Marzullo and Neiger [1991]
19
Distributed debugging (cont.)
• Goal: determine cases where global state predicate φ
• Was definitely True at some point in the execution
• Was possibly True at some point in the execution
• “Definitely” applies to actual execution, not run extrapolated
from it
• Basically, we want to know if a transitory state actually occurred
in an actual execution
•Why not worry if a stable state did?
• Can consider all linearizations H of the observed events
• Possibly φ : exists a consistent global state S through which a
linearization of H passes such that φ(S) is True
• Definitely φ: for all linearizations L of H, exists a consistent global
state S through which L passes such that φ(S) is True
20
Collecting the state [14.6.1]
• Procs pi send in initial state, then periodically later ones
• Does not interfere with execution, only delays a bit (!!)
• Only need to send updates when change in variable used in φ
• Monitor proc records state msgs from each pi in queue Qi
21
Figure 14.14 Vector timestamps and variable values for the
execution of Figure 14.9
m1 m2
Physical
p2
time
x 2= 100 x 2= 95 x 2= 90
(2,1) (2,2) (2,3)
2
Cut C
Cut C 1
Example : safety property |xi-xj| ≤ δ for all i, j in [1,N]
E.g. δ = 50 & send only “large adjustments” next slides..
Inconsistent cut C1 show violation that never happened… but C2 did
Instructor’s Guide for Coulouris, Dollimore, Kindberg and Blair, Distributed Systems: Concepts and Design Edn. 5
© Pearson Education 2012
Observing consistent global states [14.6.2]
• Recall a cut C consistent if, for every event it contains, all
events that “happened before” that event are also
contained
• i.e., ∀ events e ∈ C, fe implies that f ∈C
• Fig 14.14 & only send when adjustments “large enough”
• Upon receipt, process updates its value to that of sender
• To know of cut is consistent, processes also send vector
clocks with (changed) state
23
Observing consistent global states (cont.)
• Let
• S={s1, s2, … ,sN} be a global state at monitor, from the state msgs
• V(si) vector timestamp of state si received from process pi
• Then S is a consistent global state iff
V(si)[i] ≥ V(sj)[i] for i,j in [1,N]
• I.e., # of pi’s events known at pj when it sent sj is no more than then
number of events that had occurred at pi when it sent si.
• I.e., if one proc’s state depends on another (by happened-to), then
global state also encompasses state upon which it depends
• How to represent? Lattices (2 slides away)
• Condition depicted next…
24
Figure 14.14 REDUX Vector timestamps and variable values
for the execution of Figure 14.9
(1,0) (2,0) (3,0) (4,3)
x 1= 1 x1= 100 x1= 105 x 1= 90
p1
m1 m2
Physical
p2
time
x 2= 100 x 2= 95 x 2= 90
(2,1) (2,2) (2,3)
2
Cut C
Cut C 1
1 S 10
4 S 31 S 22
5 S 32 S 23
6 S 33
7 S 43
1 S 10
4 S 31 S 22
5 S 32 S 23
(1,0) (2,0) (3,0) (4,3)
6 S 33 x1= 1 x1= 100x1= 105 x1= 90
p1
7 S 43 m1 m2
p2
x2= 100 x2= 95 x2= 90
(2,1) (2,2) (2,3)
Cut C 2
Cut C1
Instructor’s Guide for Coulouris, Dollimore, Kindberg and Blair, Distributed Systems: Concepts and Design Edn. 5
© Pearson Education 2012
Evaluating with the lattice
• Lattice shows us all linearizations corresponding to a
history
• Evaluating possibly φ
• Start at initial stage & step through all consistent states
• Evaluate φ at each stage, stop when it evaluates to True
• Evaluating definitely φ
• Try to find a set of states through which all linearizations must pass
• Then check if the set’s states all evaluate φ to True; done if find
• E.g., φ(S30) and φ(S21) both true, and one or other must be passed
through for all executions
28
Figure 14.16: Algorithms to eval. possibly φ and definitely φ
NOTE: infinite depth
Instructor’s Guide for Coulouris, Dollimore, Kindberg and Blair, Distributed Systems: Concepts and Design Edn. 5
© Pearson Education 2012
Figure 14.17
Evaluating definitely φ