Theoretical Aspects Logical Clocks Causal Ordering

Slides:



Advertisements
Similar presentations
P1 P2 P3 x y z (0,0,0) M1 M2 M3 VP1( __, __ ) VP2( __, __ ) VP3( __, __ ) Initially Vector Time is (0,0,0) at all sites Vector at each site is empty. Note.
Advertisements

Virtual Time “Virtual Time and Global States of Distributed Systems” Friedmann Mattern, 1989 The Model: An asynchronous distributed system = a set of processes.
SES Algorithm SES: Schiper-Eggli-Sandoz Algorithm. No need for broadcast messages. Each process maintains a vector V_P of size N - 1, N the number of processes.
1 Global State $500$200 A B C1: Empty C2: Empty Global State 1 $450$200 A B C1: Tx $50 C2: Empty Global State 2 $450$250 A B C1: Empty C2: Empty Global.
Uncoordinated Checkpointing The Global State Recording Algorithm Cristian Solano.
Time and Global States Part 3 ECEN5053 Software Engineering of Distributed Systems University of Colorado, Boulder.
Synchronization Chapter clock synchronization * 5.2 logical clocks * 5.3 global state * 5.4 election algorithm * 5.5 mutual exclusion * 5.6 distributed.
CS542 Topics in Distributed Systems Diganta Goswami.
Dr. Kalpakis CMSC 621, Advanced Operating Systems. Logical Clocks and Global State.
S NAPSHOT A LGORITHM. W HAT IS A S NAPSHOT - INTUITION Given a system of processors and communication channels between them, we want each processor to.
Distributed Systems Spring 2009
CS 582 / CMPE 481 Distributed Systems
Causality & Global States. P1 P2 P Physical Time 4 6 Include(obj1 ) obj1.method() P2 has obj1 Causality violation occurs when order.
Ordering and Consistent Cuts Presented By Biswanath Panda.
CMPT 431 Dr. Alexandra Fedorova Lecture VIII: Time And Global Clocks.
Distributed Systems Fall 2009 Logical time, global states, and debugging.
CPSC 668Set 12: Causality1 CPSC 668 Distributed Algorithms and Systems Fall 2009 Prof. Jennifer Welch.
Ordering and Consistent Cuts Presented by Chi H. Ho.
EEC-681/781 Distributed Computing Systems Lecture 11 Wenbing Zhao Cleveland State University.
1 Distributed Process Management: Distributed Global States and Distributed Mutual Exclusion.
Computer Science Lecture 10, page 1 CS677: Distributed OS Last Class: Clock Synchronization Physical clocks Clock synchronization algorithms –Cristian’s.
Time, Clocks, and the Ordering of Events in a Distributed System Leslie Lamport (1978) Presented by: Yoav Kantor.
Dr. Kalpakis CMSC 621, Advanced Operating Systems. Fall 2003 URL: Logical Clocks and Global State.
Chapter 17 Theoretical Issues in Distributed Systems
Logical Clocks (2). Topics r Logical clocks r Totally-Ordered Multicasting r Vector timestamps.
Chapter 5.
CIS 720 Distributed algorithms. “Paint on the forehead” problem Each of you can see other’s forehead but not your own. I announce “some of you have paint.
Donghyun (David) Kim Department of Mathematics and Physics North Carolina Central University 1 Project Reference Some slides are in courtesy of Dr. Erciyes,
1 Consistent Global States of Distributed Systems: Fundamental Concepts and Mechanisms Author: Ozalp Babaoglu and Keith Marzullo Distributed Systems: 526.
Logical Clocks n event ordering, happened-before relation (review) n logical clocks conditions n scalar clocks condition implementation limitation n vector.
1 Causal Delivery Advanced Networks PhD. Saúl Pomares Hernández.
Lecture 6-1 Computer Science 425 Distributed Systems CS 425 / ECE 428 Fall 2013 Indranil Gupta (Indy) September 12, 2013 Lecture 6 Global Snapshots Reading:
Logical Clocks. Topics Logical clocks Totally-Ordered Multicasting Vector timestamps.
Lamport’s Logical Clocks & Totally Ordered Multicasting.
“Virtual Time and Global States of Distributed Systems”
Communication & Synchronization Why do processes communicate in DS? –To exchange messages –To synchronize processes Why do processes synchronize in DS?
Distributed Systems Fall 2010 Logical time, global states, and debugging.
Event Ordering Greg Bilodeau CS 5204 November 3, 2009.
CIS825 Lecture 2. Model Processors Communication medium.
Logical Clocks. Topics Logical clocks Totally-Ordered Multicasting Vector timestamps.
Building Dependable Distributed Systems, Copyright Wenbing Zhao
D ISTRIBUTED S YSTEM UNIT-2 Theoretical Foundation for Distributed Systems Prepared By: G.S.Mishra.
Feb 15, 2001CSCI {4,6}900: Ubiquitous Computing1 Announcements.
Logical Clocks. Topics r Logical clocks r Totally-Ordered Multicasting.
Event Ordering. CS 5204 – Operating Systems2 Time and Ordering The two critical differences between centralized and distributed systems are: absence of.
Ordering of Events in Distributed Systems UNIVERSITY of WISCONSIN-MADISON Computer Sciences Department CS 739 Distributed Systems Andrea C. Arpaci-Dusseau.
1 Chapter 11 Global Properties (Distributed Termination)
11-Jun-16CSE 542: Operating Systems1 Distributed systems Time, clocks, and the ordering of events in a distributed system Leslie Lamport. Communications.
Logical Clocks event ordering, happened-before relation (review) logical clocks conditions scalar clocks  condition  implementation  limitation vector.
Distributed Systems Lecture 6 Global states and snapshots 1.
Ordering of Events in Distributed Systems UNIVERSITY of WISCONSIN-MADISON Computer Sciences Department CS 739 Distributed Systems Andrea C. Arpaci-Dusseau.
CSCE 668 DISTRIBUTED ALGORITHMS AND SYSTEMS
Global State Recording
Theoretical Foundations
COT 5611 Operating Systems Design Principles Spring 2012
Global State Recording
Outline Theoretical Foundations - continued Vector clocks - review
Logical Clocks and Casual Ordering
Outline Theoretical Foundations - continued Lab 1
Time And Global Clocks CMPT 431.
Event Ordering.
Outline Theoretical Foundations
Chapter 5 (through section 5.4)
Uncoordinated Checkpointing
Outline Theoretical Foundations - continued
Distributed algorithms
CIS825 Lecture 5 1.
COT 5611 Operating Systems Design Principles Spring 2014
Outline Theoretical Foundations
Presentation transcript:

Theoretical Aspects Logical Clocks Causal Ordering Global State Recording Termination Detection B. Prabhakaran

Lamport’s Clock Happened before relation: Causally Ordered Events a -> b : Event a occurred before event b. Events in the same process. a -> b : If a is the event of sending a message m in a process and b is the event of receipt of the same message m by another process. a -> b, b -> c, then a -> c. “->” is transitive. Causally Ordered Events a -> b : Event a “causally” affects event b Concurrent Events a || b: if a !-> b and b !-> a B. Prabhakaran

Space-time Diagram Space e11 e12 e13 e14 P1 Internal Events Messages B. Prabhakaran

Logical Clocks Conditions satisfied: Implementation Rules: Ci is clock in Process Pi. If a -> b in process Pi, Ci(a) < Ci(b) Let a: sending message m in Pi; b : receiving message m in Pj; then, Ci(a) < Cj(b). Implementation Rules: R1: Ci = Ci + d (d > 0); clock is updated between two successive events. R2: Cj = max(Cj, tm) + d; (d > 0); When Pj receives a message m with a time stamp tm (tm assigned by Pi, the sender; tm = Ci(a), a being the event of sending message m). A reasonable value for d is 1 B. Prabhakaran

Space-time Diagram Space e11 e12 e13 e14 e15 e16 e17 P1 (1) (2) (3) (4) (5) (6) (7) (1) (2) (3) (4) (7) P2 e21 e22 e23 e24 e25 Time B. Prabhakaran

Limitation of Lamport’s Clock Space e11 e12 e13 P1 (1) (2) (3) (1) (3) (4) P2 e21 e22 e23 e31 e32 e33 P3 (1) (2) Time C(e11) < C(e32) but not causally related. This inter-dependency not reflected in Lamport’s Clock. B. Prabhakaran

Vector Clocks Keep track of transitive dependencies among processes for recovery purposes. Ci[1..n]: is a “vector” clock at process Pi whose entries are the “assumed”/”best guess” clock values of different processes. Ci[j] (j != i) is the best guess of Pi for Pj’s clock. Vector clock rules: Ci[i] = Ci[i] + d, (d > 0); for successive events in Pi For all k, Cj[k] = max (Cj[k],tm[k]), when a message m with time stamp tm is received by Pj from Pi. : For all B. Prabhakaran

Vector Clocks Comparison 1. Equal: ta = tb iff i, ta[i] = tb[i] 2. Not Equal: ta != tb iff ta[i] != tb[i], for at least one i 3. Less than or equal: ta <= tb iff ta[i] <= tb[i], for all i 4. Less than : ta < tb iff ta[i] <= tb[i] and ta[i] != tb[i], for all i 5. Concurrent: ta || tb iff ta !< tb and tb !< ta 6. Not less than or equal ... 7. Not less than .. B. Prabhakaran

Vector Clock … Space e11 e12 e13 P1 (1,0,0) (2,0,0) (3,4,1) (0,1,0) (2,2,0) (2,3,1) (2,4,1) P2 e21 e22 e23 e24 e31 e32 P3 (0,0,1) (0,0,2) Time B. Prabhakaran

Causal Ordering of Messages Space Send(M1) P1 Send(M2) P2 (1) P3 (2) Time B. Prabhakaran

Message Ordering … Not really worry about maintaining clocks. Order the messages sent and received among all processes in a distributed system. (e.g.,) Send(M1) -> Send(M2), M1 should be received ahead of M2 by all processes. This is not guaranteed by the communication network since M1 may be from P1 to P2 and M2 may be from P3 to P4. Message ordering: Deliver a message only if the preceding one has already been delivered. Otherwise, buffer it up. B. Prabhakaran

BSS Algorithm BSS: Birman-Schiper-Stephenson Protocol Broadcast based: a message sent is received by all other processes. Deliver a message to a process only if the message preceding it immediately, has been delivered to the process. Otherwise, buffer the message. Accomplished by using a vector accompanying the message. B. Prabhakaran

BSS Algorithm ... Process Pi increments the vector time VTpi[i], time stamps, and broadcasts the message m. VTpi[i] - 1 denotes the number of messages preceding m. 2. Pj != Pi receives m. m is delivered when: a. VTpj[i] == VTm[i] - 1 b. VTpj[k] >= VTm[k] for all k in {1,2,..n} - {i}, n is the total number of processes. Delayed message are queued in a sorted manner. c. Concurrent messages are ordered by time of receipt. When m is delivered at Pj, VTpj updated according Rule 2 of vector clocks. 2(a) : Pj has received all Pi’s messages preceding m. 2(b): Pj has received all other messages received by Pi before sending m. B. Prabhakaran

BSS Algorithm … (buffer) (0,0,1) (0,1,1) P1 deliver from buffer B. Prabhakaran

SES Algorithm SES: Schiper-Eggli-Sandoz Algorithm. No need for broadcast messages. Each process maintains a vector V_P of size N - 1, N the number of processes in the system. V_P is a vector of tuple (P’,t): P’ the destination process id and t, a vector timestamp. Tm: logical time of sending message m Tpi: present logical time at pi Initially, V_P is empty. B. Prabhakaran

SES Algorithm Sending a Message: Delivering a message Send message M, time stamped tm, along with V_P1 to P2. Insert (P2, tm) into V_P1. Overwrite the previous value of (P2,t), if any. (P2,tm) is not sent. Any future message carrying (P2,tm) in V_P1 cannot be delivered to P2 until tm < tP2. Delivering a message If V_M (in the message) does not contain any pair (P2, t), it can be delivered. /* (P2, t) exists */ If t > Tp2, buffer the message. (Don’t deliver). else (t < Tp2) deliver it B. Prabhakaran

SES Algorithm ... What does the condition t > Tp2 imply? t is message vector time stamp. t > Tp2 -> For all j, t[j] > Tp2[j] This implies some events occurred without P2’s knowledge in other processes. So P2 decides to buffer the message. When t < Tp2, message is delivered & Tp2 is updated with the help of V_P2 (after the merge operation). B. Prabhakaran

SES Buffering Example P1 Tp1: (1,1,0) (2,2,2) Tp2: P2 (0,1,0) (0,2,0) V_P2 empty V_P2: (P1, <0,1,0>) P3 M3 Tp3: (0,2,1) (0,2,2) V_P3: (P1,<0,1,0>) B. Prabhakaran

SES Buffering Example... M1 from P2 to P1: M1 + Tm (=<0,1,0>) + Empty V_P2 M2 from P2 to P3: M2 + Tm (<0, 2, 0>) + (P1, <0,1,0>) M3 from P3 to P1: M3 + <0,2,2> + (P1, <0,1,0>) M3 gets buffered because: Tp1 is <0,0,0>, t in (P1, t) is <0,1,0> & so Tp1 < t When M1 is received by P1: Tp1 becomes <1,1,0>, by rules 1 and 2 of vector clock. After updating Tp1, P1 checks buffered M3. Now, Tp1 > t [in (P1, <0,1,0>]. So M3 is delivered. B. Prabhakaran

SES Algorithm ... On delivering the message: Merge V_M (in message) with V_P2 as follows. If (P,t) is not there in V_P2, merge. If (P,t) is present in V_P2, t is updated with max(t in Vm, t in V_P2). Message cannot be delivered until t in V_M is greater than t in V_P2 Update site P2’s local, logical clock. Check buffered messages after local, logical clock update. B. Prabhakaran

SES Algorithm … P1 (1,2,1) (2,2,1) (0,1,1) P2 M2 (0,2,1) V_P2 is empty (0,2,2) (0,0,1) V_P3 is empty B. Prabhakaran

Handling Multicasts Each node can maintain n x n matrix M, n being the number of processes. Node i multicasts to j and k: increments Mi[i,j] and Mi[i,k]. M sent along with the message. When node j receives message m from i, it can be delivered if and only if: Mj[i,j] = Mm[i,j] - 1 Mj[k,j] >= Mm[k,j] for all k != i. Else buffer the message On message delivery: Mj[x,y] = max(Mj[x,y], Mm[x,y]) B. Prabhakaran

Handling Multicasts: Example 000 000 110 000 101 110 P1 000 110 P2 M2 000 101 110 P3 M1 000 101 110 000 110 B. Prabhakaran

Global State Global State 1 C1: Empty $500 $200 C2: Empty A B C1: Tx $50 $450 $200 C2: Empty A B Global State 3 C1: Empty $450 $250 C2: Empty A B B. Prabhakaran

Recording Global State... (e.g.,) Global state of A is recorded in (1) and not in (2). State of B, C1, and C2 are recorded in (2) Extra amount of $50 will appear in global state Reason: A’s state recorded before sending message and C1’s state after sending message. Inconsistent global state if n < n’, where n is number of messages sent by A along channel before A’s state was recorded n’ is number of messages sent by A along the channel before channel’s state was recorded. Consistent global state: n = n’ B. Prabhakaran

Recording Global State... Similarly, for consistency m = m’ m’: no. of messages received along channel before B’s state recording m: no. of messages received along channel by B before channel’s state was recorded. Also, n’ >= m, as in no system no. of messages sent along the channel be less than that received Hence, n >= m Consistent global state should satisfy the above equation. Consistent global state: Channel state: sequence of messages sent before recording sender’s state, excluding the messages received before receiver’s state was recorded. Only transit messages are recorded in the channel state. B. Prabhakaran

Recording Global State Send(Mij): message M sent from Si to Sj rec(Mij): message M received by Sj, from Si time(x): Time of event x LSi: local state at Si send(Mij) is in LSi iff (if and only if) time(send(Mij)) < time(LSi) rec(Mij) is in LSj iff time(rec(Mij)) < time(LSj) transit(LSi, LSj) : set of messages sent/recorded at LSi and NOT received/recorded at LSj B. Prabhakaran

Recording Global State … inconsistent(LSi,LSj): set of messages NOT sent/recorded at LSi and received/recorded at LSj Global State, GS: {LS1, LS2,…., LSn} Consistent Global State, GS = {LS1, ..LSn} AND for all i in n, inconsistent(LSi,LSj) is null. Transitless global state, GS = {LS1,…,LSn} AND for all i in n, transit(LSi,LSj) is null. B. Prabhakaran

Recording Global State .. M1 S1 M2 S2 LS2 M1: transit M2: inconsistent B. Prabhakaran

Recording Global State... Strongly consistent global state: consistent and transitless, i.e., all send and the corresponding receive events are recorded in all LSi. LS11 LS12 LS22 LS23 LS21 LS31 LS32 LS33 B. Prabhakaran

Chandy-Lamport Algorithm Distributed algorithm to capture a consistent global state. Communication channels assumed to be FIFO. Uses a marker to initiate the algorithm. Marker sort of dummy message, with no effect on the functions of processes. Sending Marker by P: P records its state. For each outgoing channel C, P sends a marker on C before P sends further messages along C. Receiving Marker by Q: If Q has NOT recorded its state: (a). Record the state of C as an empty sequence. (b) SEND marker (use above rule). Else (Q has recorded state before): Record the state of C as sequence of messages received along C, after Q’s state was recorded and before Q received the marker. FIFO channel condition + markers help in satisfying consistency condition. B. Prabhakaran

Chandy-Lamport Algorithm Initiation of marker can be done by any process, with its own unique marker: <process id, sequence number>. Several processes can initiate state recording by sending markers. Concurrent sending of markers allowed. One possible way to collect global state: all processes send the recorded state information to the initiator of marker. Initiator process can sum up the global state. Seq Si Sj Sc Seq’ B. Prabhakaran

Chandy-Lamport Algorithm ... Example: Pi Pj Pk Send Marker Send Marker Record channel state Record channel state Record channel state Channel state example: M1 sent to Px at t1, M2 sent to Py at t2, …. B. Prabhakaran

Chandy-Lamport Algorithm ... Pi Pj B. Prabhakaran

Cuts Cuts: graphical representation of a global state. Cut C = {c1, c2, .., cn}; ci: cut event at Si. Consistent Cut: If every message received by a Si before a cut event, was sent before the cut event at Sender. One can prove: A cut is a consistent cut iff no two cut events are causally related, i.e., !(ci -> cj) and !(cj -> ci). VTc=<3,7 ,6,4> c1 <3,2,5,4> S1 c2<2,7,6,3> S2 c3 S3 c4 S4 B. Prabhakaran

Time of a Cut C = {c1, c2, .., cn} with vector time stamp VTci. Vector time of the cut, VTc = sup(VTc1, VTc2, .., VTcn). sup is a component-wise maximum, i.e., VTci = max(VTc1[i], VTc2[i], .., VTcn[i]). Now, a cut is consistent iff VTc = (VTc1[1], VTc2[2], .., VTcn[n]). B. Prabhakaran

Termination Detection Termination: completion of the sequence of algorithm. (e.g.,) leader election, deadlock detection, deadlock resolution. Use a controlling agent or a monitor process. Initially, all processes are idle. Weight of controlling agent is 1 (0 for others). Start of computation: message from controller to a process. Weight: split into half (0.5 each). Repeat this: any time a process send a computation message to another process, split the weights between the two processes (e.g., 0.25 each for the third time). End of computation: process sends its weight to the controller. Add this weight to that of controller’s. (Sending process’s weight becomes 0). Rule: Sum of W always 1. Termination: When weight of controller becomes 1 again. B. Prabhakaran

Huang’s Algorithm B(DW): computation message, DW is the weight. C(DW): control/end of computation message; Rule 1: Before sending B, compute W1, W2 (such that W1 + W2 is W of the process). Send B(W2) to Pi, W = W1. Rule 2: Receiving B(DW) -> W = W + DW, process becomes active. Rule 3: Active to Idle -> send C(DW), W = 0. Rule 4: Receiving C(DW) by controlling agent -> W = W + DW, If W == 1, computation has terminated. B. Prabhakaran

Huang’s Algorithm P1 P1 0.5 1/4 P2 P3 P2 P3 0.5 1/2 1/8 P4 P5 P4 P5 1/2 1/8 P4 P5 P4 P5 1/16 1/16 B. Prabhakaran