Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Causality. 2 The “happens before” relation happens before (causes)

Similar presentations


Presentation on theme: "1 Causality. 2 The “happens before” relation happens before (causes)"— Presentation transcript:

1 1 Causality

2 2 The “happens before” relation happens before (causes)

3 3 A message is sent from to

4 4 and transitivity

5 5

6 6 “happens before” is a partial order Parallel events:

7 7 “happens before” is a partial order Parallel events:

8 8 We can move parallel events The happens before relation doesn’t change

9 9 We want to find a mechanism that captures the “happens before” relationship so that we use causality in various computation problems

10 10 Logical Clocks 123 1 23 45 4 In each process, the logical clock increases by 1 with each local event 0 0

11 11 12 123 5 4 Logical clocks are piggy-packed on messages 4 0 0

12 12 Logical clocks, seem that they capture the happens before relation 123 78 2456 1234567

13 13 123 78 2456 1234567 Example:

14 14 However, logical clocks cannot capture parallelism Parallel events 123 78 2456 1234567

15 15 We need another mechanism that can capture the parallelism of events

16 16 Vector Clocks Process entry

17 17 Each process increases its entry at each event increment

18 18 Each process increases its entry at each event increment

19 19 vector clocks are piggy-packed on messages The maximum of each entry

20 20 vector clocks are piggy-packed on messages

21 21 vector clocks are piggy-packed on messages

22 22

23 23 Comparison of vector clocks if for all We write

24 24 Examples:

25 25 Incomparable vector clocks We write If neither nor

26 26 Examples:

27 27 Vector clocks capture causality If then

28 28 If then By examining the vector clocks we can determine the order of events

29 29

30 30

31 31

32 32

33 33 Cuts

34 34 2 1345 1234 2134567

35 35 consists from an event from each process Cut: 2 1345 1234 2134567

36 36 no messages cross the cut Consistent cut: 2 1345 1234 2134567

37 37 messages can cross from left to right of the cut Consistent cut: 2 1345 1234 2134567

38 38 messages cross from right to left of the cut Inconsistent cut: 2 1345 1234 2134567

39 39 2 1345 1234 2134567 messages cross from right to left of the cut Inconsistent cut:

40 40 A consistent cut such that Maximal Consistent Cut Maximal Consistent Cut of : Consider some (inconsistent) cut and contains most recent events

41 41 (inconsistent cut) 2 1345 1234 2134567

42 42 maximal consistent cut 2 1345 1234 2134567 (inconsistent cut)

43 43 Theorem: For every cut, there is a unique maximal consistent cut Proof:Proof by contradiction

44 44 Assume for contradiction there are two (or more) maximal cuts of maximal consistent cuts

45 45 not maximal! It cannot be that and don’t cross

46 46 and cross

47 47 and cross new cut

48 48 and cross impossible is consistentsince

49 49 and cross impossible is consistentsince

50 50 and cross is consistent not maximal! Contradiction! End of proof

51 51 A distributed algorithm for computing the maximum consistent cut of : Use vector clocks For each processor: Find most recent event with vector clock

52 52 2 1345 1234 213456 7

53 53 2 1345 1234 213456 7

54 54 2 1345 1234 213456 7 OK

55 55 2 1345 1234 213456 7 OK

56 56 2 1345 1234 213456 7 OK

57 57 2 1345 1234 213456 7 OK

58 58 2 1345 1234 213456 7

59 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 60 A Distributed Snapshot Algorithm Upon receiving a marker message: Processor : Count local events in If then set send marker to all neighbors

61 61 2 1345 1234 2134567

62 62 m

63 63 m m m

64 64 m m m

65 65 m m m m m m m m

66 66 m m m m m m m m

67 67 m m m m m m m m m

68 68 m m m m m m m m m cut

69 69 Theorem:The cut obtained by the algorithm is consistent Proof: By contradiction

70 70 Suppose the cut is incosistent

71 71 It must be: m Impossible! End of proof (we assume FIFO)

72 Spring 2003Costas Busch72 FIFO-Broadcast

73 Spring 2003Costas Busch73 FIFO Order Messages from are received in the order they are sent from

74 Spring 2003Costas Busch74 Not FIFO-order

75 Spring 2003Costas Busch75 Messages from different processors may be received in different order FIFO order

76 Spring 2003Costas Busch76 Not FIFO-order

77 Spring 2003Costas Busch77 Why is FIFO important? Deposit $1000 ATM Bank Account Withdraw $500 $0 $1000$500 FIFO order

78 Spring 2003Costas Busch78 Why is FIFO important? Deposit $1000 ATM Bank Account Withdraw $500 $0 $500-$500 Not FIFO order Not an allowed transaction

79 Spring 2003Costas Busch79 2 A processor increments a counter when it broadcasts 1 1 1 22 1 2 A simple FIFO algorithm 12

80 Spring 2003Costas Busch80 A processor keeps track of the highest values received from other processors 2 1 1 1 22 1 2 12

81 Spring 2003Costas Busch81 Wait until all messages with smaller values from the same sender are received waitok 2 1 1 1 22 1 2 12

82 Spring 2003Costas Busch82 receive 2 1 1 1 22 1 2 12 2

83 Spring 2003Costas Busch83 Totally Ordered - Broadcast

84 Spring 2003Costas Busch84 Total Order Messages are received in the same order in every processor

85 Spring 2003Costas Busch85 Not Total Order

86 Spring 2003Costas Busch86 Total Order

87 Spring 2003Costas Busch87 Not Total Order

88 Spring 2003Costas Busch88 An Asymmetric Algorithm 1 Request a counter value counter

89 Spring 2003Costas Busch89 1 1 counter Receive a counter value

90 Spring 2003Costas Busch90 1 1 counter Broadcast 1 1 1 1

91 Spring 2003Costas Busch91 1 1 counter 1 1 1 1 2 2 2 2 2 2

92 Spring 2003Costas Busch92 2 With the counter, broadcast messages are totally ordered 1 wait ok 2 1

93 Spring 2003Costas Busch93 2 With the counter, broadcast messages are totally ordered 1 wait ok received 2 2 1 2

94 Spring 2003Costas Busch94 A Symmetric Algorithm Builds on top of FIFO It is a form of Vector Clocks

95 Spring 2003Costas Busch95 Every process has a counter On broadcast: the process sends the counter value to every boby

96 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

97 Spring 2003Costas Busch97

98 Spring 2003Costas Busch98 1 1 1

99 Spring 2003Costas Busch99 1 1 1

100 Spring 2003Costas Busch100 1 1 1 1 1 1 Special broadcast message

101 Spring 2003Costas Busch101 1 1 1 1 1 1 1 1 1

102 Spring 2003Costas Busch102 1 1 1 1 1 1 1 1 1 Actual reception of normal broadcast message

103 Spring 2003Costas Busch103 1 1 1 1 1 1 1 1 1 2 2 2 Another normal broadcast

104 Spring 2003Costas Busch104 Local vector of : receive a normal broadcast message if message’s counter is smaller or equal than each

105 Spring 2003Costas Busch105

106 Spring 2003Costas Busch106 1 1 1 1 1 1

107 Spring 2003Costas Busch107 1 1 1 1 1 1

108 Spring 2003Costas Busch108 1 1 1 1 1 1 1 1 1

109 Spring 2003Costas Busch109 1 1 1 1 1 1 1 1 1

110 Spring 2003Costas Busch110 1 1 1 1 1 1 1 1 1 Symmetry is broken with node ids

111 Spring 2003Costas Busch111 Casually Ordered - Broadcast

112 Spring 2003Costas Busch112 Casual Order Messages are received in the order they are caused

113 Spring 2003Costas Busch113 Not causal order

114 Spring 2003Costas Busch114 Casual order

115 Spring 2003Costas Busch115 Not casual order

116 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

117 Spring 2003Costas Busch117

118 Spring 2003Costas Busch118

119 Spring 2003Costas Busch119

120 Spring 2003Costas Busch120

121 Spring 2003Costas Busch121

122 Spring 2003Costas Busch122

123 Spring 2003Costas Busch123

124 Spring 2003Costas Busch124

125 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:

126 Spring 2003Costas Busch126 Relationship Between Broadcast Orders

127 Spring 2003Costas Busch127 Casual Order Casual Order does not imply Total Order a b ab ba

128 Spring 2003Costas Busch128 Casual Order Casual Order implies FIFO ab ab b a

129 Spring 2003Costas Busch129 Total Order Total Order does not imply Casual Order nor FIFO ab ab ba

130 Spring 2003Costas Busch130 FIFO FIFO does not imply Casual Order nor Total Order aab b a b


Download ppt "1 Causality. 2 The “happens before” relation happens before (causes)"

Similar presentations


Ads by Google