Ordering of Events in Distributed Systems UNIVERSITY of WISCONSIN-MADISON Computer Sciences Department CS 739 Distributed Systems Andrea C. Arpaci-Dusseau.

Slides:



Advertisements
Similar presentations
Time, Clocks, and the Ordering of Events in a Distributed System
Advertisements

Distributed Snapshots: Determining Global States of Distributed Systems - K. Mani Chandy and Leslie Lamport.
Distributed Computing 5. Snapshot Shmuel Zaks ©
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.
Distributed Computing 5. Snapshot Shmuel Zaks ©
Dr. Kalpakis CMSC 621, Advanced Operating Systems. Logical Clocks and Global State.
Distributed Systems Dinesh Bhat - Advanced Systems (Some slides from 2009 class) CS 6410 – Fall 2010 Time Clocks and Ordering of events Distributed Snapshots.
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.
Ordering and Consistent Cuts Presented By Biswanath Panda.
Distributed Systems Fall 2009 Logical time, global states, and debugging.
Ordering and Consistent Cuts
20101 Synchronization in distributed systems A collection of independent computers that appears to its users as a single coherent system.
Ordering and Consistent Cuts Presented by Chi H. Ho.
EEC-681/781 Distributed Computing Systems Lecture 11 Wenbing Zhao Cleveland State University.
Time, Clocks and the Ordering of Events in a Distributed System - by Leslie Lamport.
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 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.
Distributed Computing 5. Snapshot Shmuel Zaks ©
Lamport’s Logical Clocks & Totally Ordered Multicasting.
Distributed Systems Fall 2010 Logical time, global states, and debugging.
Event Ordering Greg Bilodeau CS 5204 November 3, 2009.
CSE 486/586, Spring 2013 CSE 486/586 Distributed Systems Global States Steve Ko Computer Sciences and Engineering University at Buffalo.
Time, Clocks, and the Ordering of Events in a Distributed System Leslie Lamport Massachusetts Computer Associates,Inc. Presented by Xiaofeng Xiao.
D u k e S y s t e m s Asynchronous Replicated State Machines (Causal Multicast and All That) Jeff Chase Duke University.
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.
Fault tolerance and related issues in distributed computing Shmuel Zaks GSSI - Feb
Ordering of Events in Distributed Systems UNIVERSITY of WISCONSIN-MADISON Computer Sciences Department CS 739 Distributed Systems Andrea C. Arpaci-Dusseau.
CS533 Concepts of Operating Systems Class 8 Time, Clocks, and the Ordering of Events in a Distributed System By Constantia Tryman.
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.
Distributed Systems Lecture 6 Global states and snapshots 1.
CSCE 668 DISTRIBUTED ALGORITHMS AND SYSTEMS
Logical time Causality between events is fundamental to the design of parallel and distributed systems. In distributed systems, it is not possible to have.
Global state and snapshot
John Kubiatowicz and Anthony D. Joseph
Global state and snapshot
Vector Clocks and Distributed Snapshots
CSE 486/586 Distributed Systems Global States
Overview of Ordering and Logical Time
EECS 498 Introduction to Distributed Systems Fall 2017
COT 5611 Operating Systems Design Principles Spring 2012
Distributed Systems CS
John Kubiatowicz Electrical Engineering and Computer Sciences
Logical Clocks and Casual Ordering
Outline Theoretical Foundations - continued Lab 1
Time And Global Clocks CMPT 431.
Outline Theoretical Foundations
Chien-Liang Fok Distribution Seminar Chien-Liang Fok
Chapter 5 Synchronization
TIME, CLOCKS AND THE ORDERING OF EVENTS IN A DISTRIBUTED SYSTEM
Distributed Systems CS
Chapter 5 (through section 5.4)
Slides for Chapter 11: Time and Global State
ITEC452 Distributed Computing Lecture 8 Distributed Snapshot
Distributed Systems CS
Chap 5 Distributed Coordination
CSE 486/586 Distributed Systems Global States
Jenhui Chen Office number:
Distributed algorithms
John Kubiatowicz Electrical Engineering and Computer Sciences
CIS825 Lecture 5 1.
CSE 542: Operating Systems
COT 5611 Operating Systems Design Principles Spring 2014
Outline Theoretical Foundations
Presentation transcript:

Ordering of Events in Distributed Systems UNIVERSITY of WISCONSIN-MADISON Computer Sciences Department CS 739 Distributed Systems Andrea C. Arpaci-Dusseau Two papers: Time, Clocks, and the Ordering of Events in a Distributed System, Lamport, 1978 Distributed Snapshots: Determining Global States of Distributed Systems, Chandy and Lamport, 1985

Motivation: Time, Clocks, Ordering To develop distributed algorithms, want all participants see messages in same order (if want same decisions!) How can distributed nodes agree on order of messages? Process A Process B Naïve: Each process believes sent message first

Motivation: Time, Clocks, Ordering When does an event precede (“happen before”) another in a distributed system? Sometimes impossible to tell; sometimes it doesn’t matter –If event A occurs on machine A, and event B occurs on machine B, but there is no communication between A and B, then did event A or event B happen first??? How can a process identify which events happened before others? Logical clocks

Terminology Distributed system: A collection of distinct processes which are spatially separated and which communicate with one another by exchanging messages How does this differ from our previous definitions? Process: A sequence of events (instructions, sending messages, receiving messages) The events within a process have a total ordering

Partial Ordering Happened before: -> Rules for ordering events a and b 1) if a and b are events in same process and a comes before b, then a->b 2) if a is the sending of a message by a process and b is receiving that message, then a->b 3) if a->b and b->c then a->c a->b: It is possible for a to causally affect b Concurrent: ‡> if a ‡> b and b ‡> a, then do not know ordering of a and b It is not possible for a to causally affect b

Space-Time Diagram Time p1 p2 p3 p4 q1 q2 q3 q4 q5 q6 q7 r1 r2 r4 r3 What is the relationship between (q3,p3)? (p1,q3)? (p2,q3)? (q3,r4)? (r1,q6)? P QR

Logical Clocks Abstract view: Logical clock is a way to assign a number to an event to express ordering No relation between logical clock and physical time Clock Ci for process Pi is a function that assigns a number Ci(a) to any event a in Pi Clock condition: For any events a, b: if a->b, then C(a) < C(b) Converse condition does not hold Can’t say concurrent events have same logical time If C(a) b

Implementation of Logical Clocks C1. If a & b are in Pi & a before b, then Ci(a) < Ci(b) IR1. (Implementation Rule) Each process Pi increments Ci between any two successive events C2. If a is sent by Pi and b is received by Pj, then Ci(a) < Cj(b) IR2. (a) If event a is the sending of message m by process Pi, then m contains a timestamp Tm=Ci(a) (b) Upon receiving m, process Pj sets Cj greater than or equal to its presents value and greater than Tm.

Logical Clocks Example p1 p2 p3 p4 q1 q2 q3 q4 q5 q6 q7 r1 r2 r4 r3 What logical clock values are possible? Assume initial C(p1)=5, C(q1)=50, C(r1)=2

Logical Clocks Example p1 p2 p3 p4 q1 q2 q3 q4 q5 q6 q7 r1 r2 r4 r3 What logical clock values are possible? Assume initial C(p1)=5, C(q1)=50, C(r1)=

Total Ordering Use logical clocks to obtain total ordering across all processes and events a => b if and only if: 1) Ci(a) < Cj(b) OR 2) Ci(a) = Cj(b) and Pi < Pj (i.e., use process ids to break ties) Partial ordering is unique, but total ordering is not! Concurrent operations can go in any order Total ordering depends upon implementation of each Ci() Total ordering depends upon tie breaking rules

Distributed State Machines Each process runs same distributed algorithm Relies upon total ordering of requests Agreed upon by all participants Can be used to ensure all see events (inputs) in same order and therefore make same decisions Idea: All requests are time-stamped, responses (acks) are time-stamped too Send time-stamped request to all processes Handle next request in total order –To know next request, must have received greater timestamp from all possible participants –Problems? Example: Mutual exclusion

Mutual Exclusion Example A B CD Request queue: Scenario: A and C want resource A and C each send request before see other’s (concurrent requests) C sends request out earlier in “physical time” How will all nodes agree who should get resource?

Mutual Exclusion Example A B CD Request queue: A - 2, C - 21

Physical Clocks Motivation: Can observe anomalous behavior if other communication channels exist between processes Useful to have physical clock with meaning in physical world Synchronize independent physical clocks, each running at slightly different rates (skew) Implementation Idea: Send timestamp with each message Receiver may update clock to timestamp+minimal network delay –Clock must always increase Lots of work in this area

Conclusions Distributed, replicated state machines useful for tolerating faults Need to construct total ordering of events to obtain same results everywhere Logical clocks very simple to implement Will see logical clocks used to update replicas

Distributed Snapshots Goal Want to record global state of distributed system (i.e., state of each process, state of each communication channel) Useful so can observe system properties –Computation terminated? –System deadlocked? –Number of tokens? Complication: Distributed system has no shared state nor shared clock Cannot record global state simultaneously everywhere Distributed snapshot: Record local state at different times and combine into meaningful picture Obtain cut in logical time, remain consistent by preserving logical ordering (if not ordering in physical time)

System Model Distributed system: Finite set of processes and channels; described by graph Processes Set of states, initial state, set of events Channels FIFO, error-free, infinite buffers, arbitrary but finite delay State: Sequence of messages sent but not yet received

Distributed Snapshot Algorithm Goal: Record local state (each process plus adjoining channels) that produces a “meaningful” global system state Idea: After local snapshot, send marker along channels Receiver records messages in channel before marker Initial: Some process decides to initiate snapshot (performed periodically)

Intuition with Logical Time S S1S1 S2S2 S3 Which snapshots are concurrent? How to reconcile S2 and S? How to reconcile S1 and S? How to reconcile S3 and S? m1m1 m2 B A

Marker Rules Marker-sending rule for p: Send marker along each channel (after recording state of p) before sending more messages Marking-receiving rule for q on channel c: if q has not recorded state yet: –record state of q –record state of c as empty if q has recorded state already: –record state of c as the msg sequence that arrived since it recorded its state Termination When state recorded of all processes and all channels Must have algorithm to collect and assemble information too

Banking Example Stable property? p1: $10 p2: $20p3: $30 $1 $3 $2 $5 $4

Banking Example p1: $10 p2: $20p3: $30 $1 $3 $2 $5 $4 p2 state: $ = 18, empty channels

Banking Example p1: $10 p2: $20p3: $30 $1 $3 $2 $5 $4 p1 state: $10-1-3=6, empty channels p3 state: $ =22, empty channels Total money? = $46

Banking Example p1: $10 p2: $20p3: $30 $1 $3 $2 $5 $4

Banking Example p1: $10 p2: $20p3: $30 $1 $3 $2 $5 $4 c: p2 from p1: nothing c: p2 f p3: c: p3 f p1: 3 c: p1 f p3: 5 p1: 6, p2: 18, p3: 22

Banking Example p1: $10 p2: $20p3: $30 $1 $3 $2 $5 $4 c p2 from p3: Never $2 and $4 simultaneously

Properties of Recorded Global State Recorded global state, S*, may not have occurred If it bothers you that S* doesn’t actually exist... Given a permutation of the actual sequence of events S* is reachable from Sinit Sfinal is reachable from S* Stable properties will hold in S* as well How to permute sequence of events? Goal: Want snapshot to correspond to single logical cut Slide events so snapshots taken at same “logical time” Some events across processes will switch order with others –Specifically, postrecorded events and prerecorded events –prerecorded events occurred before state of p was recorded –Can’t tell ordering of concurrent pre and post events

Banking Example p1: $10 p2: $20p3: $30 $1 $3 $2 $5 $4 Example: Need to swap sending $4 from p3 and receiving $2 Still logically consistent; could not observe difference pre post

Conclusions Distributed snapshots: Allow one to reconstruct valid picture of system from snapshots taken at different points in time Record individual process states plus channels Snapshots useful for determining if stable properties hold or not Recorded state S* may not correspond to “reality”, but if stable properties hold in beginning and end states, then hold in S* too