Clocks in Asynchronous Systems

Similar documents
Slides for Chapter 14: Time and Global States

Chapter 11 Time and Global States

Time is an important issue in DS

Agreement. Today. l Coordination and agreement in group communication. l Consensus

Time. To do. q Physical clocks q Logical clocks

Time. Today. l Physical clocks l Logical clocks

CS505: Distributed Systems

Consistent Global States of Distributed Systems: Fundamental Concepts and Mechanisms. CS 249 Project Fall 2005 Wing Wong

Our Problem. Model. Clock Synchronization. Global Predicate Detection and Event Ordering

416 Distributed Systems. Time Synchronization (Part 2: Lamport and vector clocks) Jan 27, 2017

Logical Time. 1. Introduction 2. Clock and Events 3. Logical (Lamport) Clocks 4. Vector Clocks 5. Efficient Implementation

CptS 464/564 Fall Prof. Dave Bakken. Cpt. S 464/564 Lecture January 26, 2014

Snapshots. Chandy-Lamport Algorithm for the determination of consistent global states <$1000, 0> <$50, 2000> mark. (order 10, $100) mark

Time in Distributed Systems: Clocks and Ordering of Events

CS505: Distributed Systems

Distributed Computing. Synchronization. Dr. Yingwu Zhu

Cuts. Cuts. Consistent cuts and consistent global states. Global states and cuts. A cut C is a subset of the global history of H

CS 425 / ECE 428 Distributed Systems Fall Indranil Gupta (Indy) Oct. 5, 2017 Lecture 12: Time and Ordering All slides IG

Distributed Algorithms Time, clocks and the ordering of events

Figure 10.1 Skew between computer clocks in a distributed system

Today. Vector Clocks and Distributed Snapshots. Motivation: Distributed discussion board. Distributed discussion board. 1. Logical Time: Vector clocks

Distributed Algorithms (CAS 769) Dr. Borzoo Bonakdarpour

Distributed systems Lecture 4: Clock synchronisation; logical clocks. Dr Robert N. M. Watson

7680: Distributed Systems

Clock Synchronization

Distributed Systems Fundamentals

A subtle problem. An obvious problem. An obvious problem. An obvious problem. No!

DISTRIBUTED COMPUTER SYSTEMS

Distributed Systems Time and Global State

Chandy-Lamport Snapshotting

Absence of Global Clock

Distributed Systems 8L for Part IB

Causality and physical time

Distributed Systems Principles and Paradigms

Distributed Systems Principles and Paradigms. Chapter 06: Synchronization

CS 347 Parallel and Distributed Data Processing

Causality and Time. The Happens-Before Relation

Distributed Systems. 06. Logical clocks. Paul Krzyzanowski. Rutgers University. Fall 2017

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

Distributed Systems. Time, Clocks, and Ordering of Events

1 Introduction During the execution of a distributed computation, processes exchange information via messages. The message exchange establishes causal

Agreement Protocols. CS60002: Distributed Systems. Pallab Dasgupta Dept. of Computer Sc. & Engg., Indian Institute of Technology Kharagpur

1 Introduction During the execution of a distributed computation, processes exchange information via messages. The message exchange establishes causal

MAD. Models & Algorithms for Distributed systems -- 2/5 -- download slides at

Distributed Algorithms

Failure detectors Introduction CHAPTER

On Equilibria of Distributed Message-Passing Games

Real-Time Course. Clock synchronization. June Peter van der TU/e Computer Science, System Architecture and Networking

Asynchronous Models For Consensus

Distributed Mutual Exclusion Based on Causal Ordering

Coordination. Failures and Consensus. Consensus. Consensus. Overview. Properties for Correct Consensus. Variant I: Consensus (C) P 1. v 1.

Causal Broadcast Seif Haridi

arxiv: v1 [cs.dc] 22 Oct 2018

Unreliable Failure Detectors for Reliable Distributed Systems

Causal Consistency for Geo-Replicated Cloud Storage under Partial Replication

Shared Memory vs Message Passing

Chapter 7 HYPOTHESIS-BASED INVESTIGATION OF DIGITAL TIMESTAMPS. 1. Introduction. Svein Willassen

CS505: Distributed Systems

The Weakest Failure Detector to Solve Mutual Exclusion

Clock Synchronization

Distributed Systems. Time, clocks, and Ordering of events. Rik Sarkar. University of Edinburgh Spring 2018

Consensus. Consensus problems

Early consensus in an asynchronous system with a weak failure detector*

Fault-Tolerant Consensus

Do we have a quorum?

Analysis of Bounds on Hybrid Vector Clocks

High Performance Computing

AGREEMENT PROBLEMS (1) Agreement problems arise in many practical applications:

Eventually consistent failure detectors

Failure Detectors. Seif Haridi. S. Haridi, KTHx ID2203.1x

A Communication-Induced Checkpointing Protocol that Ensures Rollback-Dependency Trackability

C 1. Recap: Finger Table. CSE 486/586 Distributed Systems Consensus. One Reason: Impossibility of Consensus. Let s Consider This

S1 S2. checkpoint. m m2 m3 m4. checkpoint P checkpoint. P m5 P

6.852: Distributed Algorithms Fall, Class 10

Dynamic Group Communication

Causality & Concurrency. Time-Stamping Systems. Plausibility. Example TSS: Lamport Clocks. Example TSS: Vector Clocks

Decentralized Control of Discrete Event Systems with Bounded or Unbounded Delay Communication

A VP-Accordant Checkpointing Protocol Preventing Useless Checkpoints

Efficient Notification Ordering for Geo-Distributed Pub/Sub Systems

THE WEAKEST FAILURE DETECTOR FOR SOLVING WAIT-FREE, EVENTUALLY BOUNDED-FAIR DINING PHILOSOPHERS. A Dissertation YANTAO SONG

Automatic Synthesis of Distributed Protocols

Section 6 Fault-Tolerant Consensus

CS5412: REPLICATION, CONSISTENCY AND CLOCKS

Time. Lakshmi Ganesh. (slides borrowed from Maya Haridasan, Michael George)

Notes on BAN Logic CSG 399. March 7, 2006

Accurate Event Composition

Approximate Synchrony: An Abstraction for Distributed Time-Synchronized Systems

Finally the Weakest Failure Detector for Non-Blocking Atomic Commit

The Weakest Failure Detector for Wait-Free Dining under Eventual Weak Exclusion

Byzantine Agreement. Gábor Mészáros. CEU Budapest, Hungary

6.852: Distributed Algorithms Fall, Class 8

cs/ee/ids 143 Communication Networks

7. Queueing Systems. 8. Petri nets vs. State Automata

Introduction to Model Checking. Debdeep Mukhopadhyay IIT Madras

arxiv: v1 [cs.dc] 26 Nov 2018

MAD. Models & Algorithms for Distributed systems -- 2/5 -- download slides at h9p://people.rennes.inria.fr/eric.fabre/

Degradable Agreement in the Presence of. Byzantine Faults. Nitin H. Vaidya. Technical Report #

An Indian Journal FULL PAPER. Trade Science Inc. A real-time causal order delivery approach in largescale ABSTRACT KEYWORDS

Failure Detection and Consensus in the Crash-Recovery Model

Immediate Detection of Predicates in Pervasive Environments

Transcription:

Clocks in Asynchronous Systems The Internet Network Time Protocol (NTP) 8 Goals provide the ability to externally synchronize clients across internet to UTC provide reliable service tolerating lengthy losses of connectivity enable clients to resynchronize sufficiently fuently to offset typical hw drift rates provide protection against interference 8 Synchronization subnets strata 1 UTC strata 2 strata 3 (user workstations) Distributed Systems - Fall 2001 III - 13 Stefan Leue 2001

Clocks in Asynchronous Systems The Internet Network Time Protocol (NTP) 8 layered client-server architecture, based on UDP message passing 8 synchronization at clients with higher strata number less accurate due to increased latency to strata 1 time server 8 failure robustness: if a strata 1 server fails, it may become a strata 2 server that is being synchronized though another strata 1 server 8 modes multicast: ione computer periodically multicasts time information to all other computers on the network ithese adjust their clock assuming a very small transmission delay ionly suitable for high speed LANs, yielding low but usually acceptable synchronization procedure-call: similar to Christian s protocol iserver accepts uests from clients iapplicable where higher accuracy is needed, or where multicast is not supported by the network s hard- and software symmetric: ito be used where high accuracy is needed Distributed Systems - Fall 2001 III - 14 Stefan Leue 2001

Clocks in Asynchronous Systems The Internet Network Time Protocol (NTP) 8 protocol mechanism for procedure-call and symmetric modes all messages carry timing history information ilocal timestamps of send and receive of previous NTP message ilocal timestamp of send of this message <T i-3, T i-2, T i-1, m > ifor each pair i of messages m, m exchanged between two servers the following values are being computed (based on the three values carried with the message and the fourth value obtained through local timestamping): * offset o i : estimate for the actual offset between two clocks * delay d i : total transmission time for the pair of messages Distributed Systems - Fall 2001 III - 15 Stefan Leue 2001

Clocks in Asynchronous Systems The Internet Network Time Protocol (NTP) τ+o τ ilet o the true offset of B s clock relative to A s clock, and let t and t the actual transmission times of m and m idelay T i-2 = T i-3 + t + o and T i = T i-1 + t - o which leads to d i = t + t = T i-2 -T i-3 + T i -T i-1 ioffset o = o i + (t - t )/2, where o i = (T i-2 -T i-3 + T i-1 -T i )/2 iestimate and accuracy: using t, t 0 it can be shown that o i -d i /2 o o i + d i /2 hence, o i is an estimate for o, and d i is a measure for the estimate s accuracy Distributed Systems - Fall 2001 III - 16 Stefan Leue 2001

Clocks in Asynchronous Systems The Internet Network Time Protocol (NTP) 8 Use of statistical algorithms based on the 8 most recent <o i, d i > pairs to determine quality of estimates 8 The value of o i that corresponds to the minimum d i is chosen as an estimate for o 8 Time server communicates with multiple peers and eliminates peers with unreliable data, favours peers with higher strata number (e.g., for primary synchronization partner selection). 8 NTP phase lock loop model: modify local clock in accordance with observed drift rate 8 Experiments achieve synchronization accuracies of 10s msecs over Internet, and 1 msec on LAN using NTP Distributed Systems - Fall 2001 III - 17 Stefan Leue 2001

Event Ordering Clock synchronization and ordering of events 8 Consider: with achievable internal synchronization of clocks (skew of about 10-3 sec), how many processor instructions can be executed during that skew? Intel Pentium 4 iup to 2 GHz processor fuency = 2 * 10 9 processor cycles per second 8 Consequence: Clock synchronization (internal and external) cannot be sufficiently precise in order to use timestamping for the determination of total event orderings in different processes in a distributed system Distributed Systems - Fall 2001 III - 18 Stefan Leue 2001

Event Ordering Lamport s happened-before relation 8 Basic observations if two events happen in the same process p i, then they occurred in the order in which p i observed them (c.f., the local happened before relation 4) for any message passing, the send event occurs before the receive event 8 The HB (happened before) relation HB1: for any pair of events e and e, if there is a process p i such that e 4 e, then e e HB2: for any pair of events e and e and for any message m, if e = send(m) and e = receive(m), then e e HB3: if e, e and e are events and if e e and e e, then e e (HB is identical to its transitive closure) 8 HB defines a partial order Distributed Systems - Fall 2001 III - 19 Stefan Leue 2001

Event Ordering Lamport s happened-before relation 8 Consequence for any tuple e e ieither e and e are direct or indirect successors in the same process, or ithere are events e and e and a message m such that e e and e e and e = send(m) and e = receive(m) e e does not necessarily express causality between e and e 8 Concurrency for all e, e, if e not e and e not e, then we say that e and e are concurrent (also written as e e ) Distributed Systems - Fall 2001 III - 20 Stefan Leue 2001

Logical Clocks Lamport s logical clocks 8 logical clocks: permit inference of the event ordering 8 monotonically increasing counters that impose a total ordering of the observed events 8 every p i maintains logical clock L i 8 L(e) (or L i (e)): timestamp of event e (at process i) 8 messages piggiback the timestamp of the send event 8 rules to update logical clocks and message time stamps LC1: L i is incremented before each event at p i LC2: a process i piggybacks L i on every message sent LC3: on receiving (m, t), a process p j computes L j := max(l j, t), increments L j, and then timestamps receive(m, t) Distributed Systems - Fall 2001 III - 21 Stefan Leue 2001

Logical Clocks Lamport s logical clocks 8 Note e e L(e) < L(e ) but L(e) < L(e ) not e e 8 Possible to augment partial order of timestamps to total order, for instance by using the process number can be used for instance to deteminize access of concurrent processes awaiting entry into critical section Distributed Systems - Fall 2001 III - 22 Stefan Leue 2001

Vector Clocks Vector Clocks 8 Overcome weakness of Lamport s logical clocks: array of N integers each process i keeps own vector clock V i [1,..N] piggybacking of timestamps as in Lamport s protocol clock update rules VC1: Initially, all clocks are 0 on all components VC2: i sets V i [i] := V i [i] + 1 just before timestamping an event VC3: i includes t= V i in every message (piggybacking) VC4: i receives a timestamp t, then V i [j] := max(v i [i], t[j]), j=1,..,n ( merge ) Distributed Systems - Fall 2001 III - 23 Stefan Leue 2001

Vector Clocks Vector Clocks 8 Observation V i [j] is the number of events in j that i has potentially been affected by. 8 Vector timestamp comparison: V = V iff V[j] = V [j] j=1,..,n V V iff V[j] V [j] j=1,..,n V < V iff V V and V V 8 In example V(b) < V(d) V(e) unordered to V(d), i.e., e d 8 Theorem e e L(e) < L(e ) 8 Critique storage and message overhead proportional to N matrix clocks: reduced message overhead through partial vector transmission and local clock estimation Distributed Systems - Fall 2001 III - 24 Stefan Leue 2001

Global States Problems that would uire the view on a global state 8 Distributed deadlock detection: is there a cyclic wait-for-graph amongst processes and resources in the system? problem: system state changes why we conduct observation, hence we may get an inaccurate observation result m p1 r1 r2 p2 rel wait rel wait Distributed Systems - Fall 2001 III - 25 Stefan Leue 2001

Global States Problems that would uire the view on a global state 8 Distributed deadlock detection: is there a cyclic wait-for-graph amongst processes and resources in the system? problem: system state changes why we conduct observation, hence we may get an inaccurate observation result m p1 r1 r2 p2 r1 rel p1 p2 r2 Distributed Systems - Fall 2001 III - 26 Stefan Leue 2001

Global States Problems that would uire the view on a global state 8 Distributed deadlock detection: is there a cyclic wait-for-graph amongst processes and resources in the system? problem: system state changes why we conduct observation, hence we may get an inaccurate observation result m p1 r1 r2 p2 r1 rel p1 p2 r2 Distributed Systems - Fall 2001 III - 27 Stefan Leue 2001

Global States Problems that would uire the view on a global state 8 Distributed garbage collection: is there any reference to an object left? 8 Distributed termination detection: is there either an active process left or is any process activation message in transit? Distributed Systems - Fall 2001 III - 28 Stefan Leue 2001

Global States Observability 8 process states and communication status 8 due to inability to synchronize clocks global states cannot be observed based on physical clock timestamps 8 we can observe events and local states of processes, and thereby infer the states of the communication channels Cuts 8 assemble an assumed global system state from state information of the processes, but such that the resulting cut through the system is consistent only events that could have happened simultaneously (concurrent events) are part of the same cut, and the cut includes no events that are the effect of another event in the relation without that the cause is also part of the cut Distributed Systems - Fall 2001 III - 29 Stefan Leue 2001

Cuts 8 example of an inconsistent cut Global States m p1 r1 r2 p2 rel Distributed Systems - Fall 2001 III - 30 Stefan Leue 2001

Global States Cuts 8 history of process i: h i = < c, e i1, e i2,...> each e i k corresponds to either a send, receive or internal action 8 s i k describes the state of process i immediately preceding the k-th event 8 record send and receive events as part of the state -> recovering of channel information 8 global history H = (h 1,h 2,.., h N ) 8 cut C = (h 1 c1, h 2 c2,.., h N cn ) such that ( i)(h i ci a prefix of h i ) 8 consistent cut Let C a cut. C is consistent if for every event e such that there exists an i and a j such that h ji = e the following holds true: ifor any f such that f e, then there exists a h kl in C such that h kl = f. Distributed Systems - Fall 2001 III - 31 Stefan Leue 2001

Global States Consistent global states 8 state of s i in cut C is that of p i immediately succeeding the last event processed by p i in C (i.e., e ci i ) 8 global system state S = (s 1, s 2,.., s N ) 8 a consistent global system state is one that corresponds to a consistent cut Distributed Systems - Fall 2001 III - 32 Stefan Leue 2001

Global States Global state sequences 8 consider a system as evolving in a sequence of global state transitions S 0 S 1 S 2... precisely one process performs a local transition in every step of the sequence describes a partial order of all events in the system concurrent events can be thought of as having happened in some total order (linearization) that is consistent with the partial order described through S is reachable from a state S if there is a linearization that passes through S and then S possible to further formalize these concepts Distributed Systems - Fall 2001 III - 33 Stefan Leue 2001

Global States State Properties 8 express properties of the system by defining predicates to be evaluated on states e.g., x(s i ) = 5 num_crit(s i ) <= 1 8 safety properties: No bad thing will ever happen, e.g. the system is never deadlocked (a stable predicate - once the system is deadlocked, it will remain so forever) the sum of money in the electronic payment system is constant there is never more than one process in the critical section Distributed Systems - Fall 2001 III - 34 Stefan Leue 2001

Global States State Properties 8 liveness properties: Eventually something good will happen, e.g. the system will eventually make progress the system will eventually terminated every sent message will eventually be received (leadsto) if a process uests access to the critical section infinitely often, it will be granted access infinitely often (strong fairness) Distributed Systems - Fall 2001 III - 35 Stefan Leue 2001

Snapshots Observation of Global States 8 impossibility to obtain momentaneous global state information 8 observe global states such that they consist of local states that could have been observed all at the same time no ordering violation within processes no causality violation for send/receive message events 8 naive logical time based snapshot algorithm given time t known to all processes 1.. N for which snapshot is sought idetermine the state of each process after events with time stamp less than or equal to t ifor every pair (x, y) of processes determine, according to the local event history for x and y, which messages have been sent but are not yet received at time t - those messges are part of the state problem: uires maintenance of logical clocks Distributed Systems - Fall 2001 III - 36 Stefan Leue 2001

Snapshots Chandy-Lamport Algorithm for the determination of consistent global states 8 goal: observation of consistent global states without maintenance of logical clocks 8 idea use marker messages broadcasted in the (fully connected) distributed system to distinguish messages sent before or at t from those after t causes processes to locate local and channel state information, does not include gathering of local state information to form global state 8 assumptions perfect communication: no loss, corruption, reordering or duplication of messages occurs, and messages sent will eventually be delivered unidirectional FIFO channels the communication graph consisting of nodes corresponding to processes and directed edges corresponding to the channels is strongly connected (there s a path from every process to every other process) any process may initiate a snapshot-taking at any time normal system execution continues during snapshot-taking Distributed Systems - Fall 2001 III - 37 Stefan Leue 2001