Distributed systems Causal Broadcast Prof R Guerraoui Distributed
Distributed systems Causal Broadcast Prof R. Guerraoui Distributed Programming Laboratory 1
Overview Intuitions: why causal broadcast? Specifications of causal broadcast Algorithms: A non-blocking algorithm using the past and A blocking algorithm using vector clocks 2
Broadcast A deliver m B m broadcast deliver C 3
Intuitions (1) So far, we did not consider ordering among messages; In particular, we considered messages to be independent Two messages from the same process might not be delivered in the order they were broadcast A message m 1 that causes a message m 2 might be delivered by some process after m 2 4
Intuitions (2) Consider a system of news where every new event that is displayed in the screen contains a reference to the event that caused it, e. g. , a comment on some information includes a reference to the actual information Even uniform reliable broadcast does not guarantee such a dependency of delivery Causal broadcast alleviates the need for the application to deal with such dependencies 5
Modules of a process indication request indication 6
Overview Intuitions: why causal broadcast? Specifications of causal broadcast Algorithms: A non-blocking algorithm using the past and A blocking algorithm using vector clocks 7
Causal broadcast Events Request: <co. Broadcast, m> Indication: <co. Deliver, src, m> • Property: • Causal Order (CO) 8
Causality Let m 1 and m 2 be any two messages: m 1 -> m 2 (m 1 causally precedes m 2) iff C 1 (FIFO order). Some process pi broadcasts m 1 before broadcasting m 2 C 2 (Local order). Some process pi delivers m 1 and then broadcasts m 2 C 3 (Transitivity). There is a message m 3 such that m 1 -> m 3 and m 3 - > m 2 9
Causal broadcast Events Request: <co. Broadcast, m> Indication: <co. Deliver, src, m> • Property: • CO: If any process pi delivers a message m 2, then pi must have delivered every message m 1 such that m 1 -> m 2 10
Causality ? delivery p 1 m 1 p 2 delivery m 1 m 2 p 3 delivery 11
Causality ? delivery p 1 m 1 p 2 delivery m 1 m 2 p 3 delivery 12
Causality ? delivery p 1 delivery m 2 m 1 p 2 delivery m 2 p 3 m 1 delivery 13
Reliable causal broadcast (rcb) Events Request: <rco. Broadcast, m> Indication: <rco. Deliver, src, m> • Properties: • RB 1, RB 2, RB 3, RB 4 + • CO 14
Uniform causal broadcast (ucb) Events Request: <uco. Broadcast, m> Indication: <uco. Deliver, src, m> • Properties: • URB 1, URB 2, URB 3, URB 4 + • CO 15
Overview Intuitions: why causal broadcast? Specifications of causal broadcast Algorithms: A non-blocking algorithm using the past and A blocking algorithm using vector clocks 16
Algorithms We present reliable causal broadcast algorithms using reliable broadcast We obtain uniform causal broadcast algorithms by using instead an underlying uniform reliable broadcast 17
Algorithm 1 Implements: Reliable. Causal. Order. Broadcast (rco). Uses: Reliable. Broadcast (rb). upon event < Init > do delivered : = past : = empty; upon event < rco. Broadcast, m> do trigger < rb. Broadcast, [Data, past, m]>; past : = past U {[self, m]}; 18
Algorithm 1 (cont’d) upon event <rb. Deliver, pi, [Data, pastm, m]> do if m not in delivered then (*) forall [sn, n] in pastm do if n not in delivered then trigger < rco. Deliver, sn, n>; delivered : = delivered U {n}; past : = past U {[sn, n]}; 19
Algorithm 1 (cont’d) (*) … … … trigger <rco. Deliver, pi, m>; delivered : = delivered U {m}; past : = past U {[pi, m]}; 20
Algorithm 1 p 1 m 2(m 1) m 2 m 1 p 2 m 1 m 2(m 1) p 3 m 1 m 2 21
Algorithm 1 p 1 m 2(m 1) m 1 p 2 m 1 m 2(m 1) p 3 m 1 m 2 22
Uniformity Algorithm 1 ensures causal reliable broadcast If we replace reliable broadcast with uniform reliable broadcast, Algorithm 1 would ensure uniform causal broadcast 23
Algorithm 1’ (gc) Implements: Garbage. Collection (+ Algo 1). Uses: Reliable. Broadcast (rb). Perfect. Failure. Detector(P). upon event < Init > do delivered : = past : = empty; correct : = S; ackm : = (for all m); 24
Algorithm 1’ (gc – cont’d) upon event < crash, pi > do correct : = correct {pi} • upon for some m delivered: self ackm do • ackm : = ackm U {self}; • trigger < rb. Broadcast, [ACK, m]>; 25
Algorithm 1’ (gc – cont’d) upon event <rb. Deliver, pi, [ACK, m]> do ackm : = ackm U {pi}; if forall pj correct: pj ackm do past : = past {[sm, m]}; 26
Algorithm 2 Implements: Reliable. Causal. Order. Broadcast (rco). Uses: Reliable. Broadcast (rb). upon event < Init > do for all pi S: VC[pi] : = 0; upon event < rco. Broadcast, m> do VC[self] : = VC[self] + 1. trigger < rb. Broadcast, [Data, VC, m]>; 27
Algorithm 2 upon event <rb. Deliver, pj, [Data, VCm, m]> do wait until ( (VC[pj] VCm[pj] – 1) and (for all pk ≠ pj: VC[pk] VCm[pk])); trigger < rco. Deliver, pj, m>; if pj ≠ self then VC[pj] : = VC[pj] + 1. 28
Algorithm 2 m 1 p 1 m 1 [1, 0, 0] p 2 p 3 m 1 m 2 m 2 [2, 0, 0] m 1 [1, 0, 0] m 2 m 1 29
Algorithm 2 m 1 p 1 m 1 [1, 0, 0] p 2 p 3 m 1 m 2 [1, 1, 0] m 2 m 1 [1, 0, 0] m 2 m 1 30
- Slides: 30