1 Causality
2 The “happens before” relation happens before (causes)
3 A message is sent from to
4 and transitivity
5
6 “happens before” is a partial order Parallel events:
7 “happens before” is a partial order Parallel events:
8 We can move parallel events The happens before relation doesn’t change
9 We want to find a mechanism that captures the “happens before” relationship so that we use causality in various computation problems
10 Logical Clocks In each process, the logical clock increases by 1 with each local event 0 0
Logical clocks are piggy-packed on messages 4 0 0
12 Logical clocks, seem that they capture the happens before relation
Example:
14 However, logical clocks cannot capture parallelism Parallel events
15 We need another mechanism that can capture the parallelism of events
16 Vector Clocks Process entry
17 Each process increases its entry at each event increment
18 Each process increases its entry at each event increment
19 vector clocks are piggy-packed on messages The maximum of each entry
20 vector clocks are piggy-packed on messages
21 vector clocks are piggy-packed on messages
22
23 Comparison of vector clocks if for all We write
24 Examples:
25 Incomparable vector clocks We write If neither nor
26 Examples:
27 Vector clocks capture causality If then
28 If then By examining the vector clocks we can determine the order of events
29
30
31
32
33 Cuts
35 consists from an event from each process Cut:
36 no messages cross the cut Consistent cut:
37 messages can cross from left to right of the cut Consistent cut:
38 messages cross from right to left of the cut Inconsistent cut:
messages cross from right to left of the cut Inconsistent cut:
40 A consistent cut such that Maximal Consistent Cut Maximal Consistent Cut of : Consider some (inconsistent) cut and contains most recent events
41 (inconsistent cut)
42 maximal consistent cut (inconsistent cut)
43 Theorem: For every cut, there is a unique maximal consistent cut Proof:Proof by contradiction
44 Assume for contradiction there are two (or more) maximal cuts of maximal consistent cuts
45 not maximal! It cannot be that and don’t cross
46 and cross
47 and cross new cut
48 and cross impossible is consistentsince
49 and cross impossible is consistentsince
50 and cross is consistent not maximal! Contradiction! End of proof
51 A distributed algorithm for computing the maximum consistent cut of : Use vector clocks For each processor: Find most recent event with vector clock
OK
OK
OK
OK
59 Distributed Snapshot A set of processors initiate the computation for obtaining a global snapshot The cut contains the state of at least one processor in in the initiation (these processors receive special marker messages from the system)
60 A Distributed Snapshot Algorithm Upon receiving a marker message: Processor : Count local events in If then set send marker to all neighbors
62 m
63 m m m
64 m m m
65 m m m m m m m m
66 m m m m m m m m
67 m m m m m m m m m
68 m m m m m m m m m cut
69 Theorem:The cut obtained by the algorithm is consistent Proof: By contradiction
70 Suppose the cut is incosistent
71 It must be: m Impossible! End of proof (we assume FIFO)
Spring 2003Costas Busch72 FIFO-Broadcast
Spring 2003Costas Busch73 FIFO Order Messages from are received in the order they are sent from
Spring 2003Costas Busch74 Not FIFO-order
Spring 2003Costas Busch75 Messages from different processors may be received in different order FIFO order
Spring 2003Costas Busch76 Not FIFO-order
Spring 2003Costas Busch77 Why is FIFO important? Deposit $1000 ATM Bank Account Withdraw $500 $0 $1000$500 FIFO order
Spring 2003Costas Busch78 Why is FIFO important? Deposit $1000 ATM Bank Account Withdraw $500 $0 $500-$500 Not FIFO order Not an allowed transaction
Spring 2003Costas Busch79 2 A processor increments a counter when it broadcasts A simple FIFO algorithm 12
Spring 2003Costas Busch80 A processor keeps track of the highest values received from other processors
Spring 2003Costas Busch81 Wait until all messages with smaller values from the same sender are received waitok
Spring 2003Costas Busch82 receive
Spring 2003Costas Busch83 Totally Ordered - Broadcast
Spring 2003Costas Busch84 Total Order Messages are received in the same order in every processor
Spring 2003Costas Busch85 Not Total Order
Spring 2003Costas Busch86 Total Order
Spring 2003Costas Busch87 Not Total Order
Spring 2003Costas Busch88 An Asymmetric Algorithm 1 Request a counter value counter
Spring 2003Costas Busch counter Receive a counter value
Spring 2003Costas Busch counter Broadcast
Spring 2003Costas Busch counter
Spring 2003Costas Busch92 2 With the counter, broadcast messages are totally ordered 1 wait ok 2 1
Spring 2003Costas Busch93 2 With the counter, broadcast messages are totally ordered 1 wait ok received
Spring 2003Costas Busch94 A Symmetric Algorithm Builds on top of FIFO It is a form of Vector Clocks
Spring 2003Costas Busch95 Every process has a counter On broadcast: the process sends the counter value to every boby
Spring 2003Costas Busch96 On reception of a message: If received counter value is higher than local value, then: Update local counter to new value Broadcast new counter value to everybody else
Spring 2003Costas Busch97
Spring 2003Costas Busch
Spring 2003Costas Busch
Spring 2003Costas Busch Special broadcast message
Spring 2003Costas Busch
Spring 2003Costas Busch Actual reception of normal broadcast message
Spring 2003Costas Busch Another normal broadcast
Spring 2003Costas Busch104 Local vector of : receive a normal broadcast message if message’s counter is smaller or equal than each
Spring 2003Costas Busch105
Spring 2003Costas Busch
Spring 2003Costas Busch
Spring 2003Costas Busch
Spring 2003Costas Busch
Spring 2003Costas Busch Symmetry is broken with node ids
Spring 2003Costas Busch111 Casually Ordered - Broadcast
Spring 2003Costas Busch112 Casual Order Messages are received in the order they are caused
Spring 2003Costas Busch113 Not causal order
Spring 2003Costas Busch114 Casual order
Spring 2003Costas Busch115 Not casual order
Spring 2003Costas Busch116 The Total Order algorithms we described are also Casual Order algorithms Observation: There is a more efficient algorithm in terms of message complexity
Spring 2003Costas Busch117
Spring 2003Costas Busch118
Spring 2003Costas Busch119
Spring 2003Costas Busch120
Spring 2003Costas Busch121
Spring 2003Costas Busch122
Spring 2003Costas Busch123
Spring 2003Costas Busch124
Spring 2003Costas Busch125 Processor officially receives a message from with vector clock 1) All messages from smaller or equal to arrive 2) All messages from smaller than arrive When:
Spring 2003Costas Busch126 Relationship Between Broadcast Orders
Spring 2003Costas Busch127 Casual Order Casual Order does not imply Total Order a b ab ba
Spring 2003Costas Busch128 Casual Order Casual Order implies FIFO ab ab b a
Spring 2003Costas Busch129 Total Order Total Order does not imply Casual Order nor FIFO ab ab ba
Spring 2003Costas Busch130 FIFO FIFO does not imply Casual Order nor Total Order aab b a b