issues with clocks context
play

Issues with Clocks Context The tree correction protocol was based - PowerPoint PPT Presentation

Issues with Clocks Context The tree correction protocol was based on the idea of local detection and correction. Protocols of this type are complex to build We will study some of the classic protocols that help solve different


  1. Issues with Clocks

  2. Context • The tree correction protocol was based on the idea of local detection and correction. • Protocols of this type are complex to build • We will study some of the classic protocols that help solve different problems

  3. Models • We reviewed the idea of different models – Higher level models make it easier to write the programs – Lower level models are easy to implement

  4. Strongest vs Weakest Model • What is strongest model? – No private memory – Can update all variables at once – Essentially a centralized program • What is the weakest model – Process speed arbitrary – No bounds on delays – No global time • Which should we study first?

  5. Asynchronous Model • Fairly weak model – No global clock – No shared memory – Arbitrary process speed – Arbitrary message delays – We will assume messages are eventually delivered but after arbitrary delay

  6. Problems in Asynchronous Systems • We will study problems that we solve easily in centralized systems – Examples: • Clocks • Ordering among events • Checkpoints • .. • We will study solving these problems in asynchronous systems

  7. Use of Clocks • Clocks allow us to order events • In asynchronous systems, there is no notion of time. • What is the purpose of time – To say: something happened at 5pm • We cannot do this in asynchronous systems – To say: x1 happened first then y1 • We can do this sometimes in asynchronous systems – E.g., the class began before it ended

  8. Problem • Lack of global time – Need to compare different events in a distributed system • In asynchronous systems, time cannot be used to order events – We need to develop an alternative to order events in such a system

  9. Problem (Continued) • Consider the problem of detecting insider trading in a stock exchange – Assume that no communication occurs outside the computer systems – Each entity is represented by a computer and they communicate among themselves – Whenever a process sends a message, it includes ALL the information it has learnt so far • Lets not worry about the cost of implementing this – Each entity is required to follow the protocol you choose

  10. Problem (Continued) • Consider two events – An inside event, say e , that affects the company A – An event f, where an officer, X, of company A sells stock • Question – Is it possible that X is guilty of insider trading?

  11. Situation 1 • Assume global time – Event e occurred at 8am – Event f occurred at 10am (same day) – Answer: – Event e occurred at 10am – Event f occurred at 8am (same day) – Answer:

  12. Approach • What we need is a way to define causality – Can event e affect event f ? – This is defined as the happened before relation – Please do not confuse it with the English meaning of this

  13. A Realistic Variation • Consider a experiment that you are performing that includes – Events e and event f – Event f is a safety violation – Can changing what happens in event e affect what happens in f? • Important in debugging, checkpointing, etc.

  14. An Example Consider the following code segment x = 2; GOTO L1 x = 3 L2 z = y /x L1 x = x - 2 GOTO L2

  15. Another Problem from Debugging • Consider the requirement: – Valve must be open if pressure exceeds 10 – Event e : at time 8:00:00:valve = open – Event f : at time 8:00:01, pressure = 11 – Looks ok. – But is it possible that due to some race conditions (e.g., processor @e being slow) delays e and violates this constraint.

  16. happened before • Let a, b, c be events – An event can be a local event, send event or a receive event • Definition : • a  b (read as a happened before b) iff either one of the following condition is true – a and b are events on the same process and a occurred before b – a is a send event and b is the corresponding receive event – there exists event c such that a  c and c  b

  17. Revisiting the Previous Problems • Consider two events – An inside event, say e , that affects the company A – An event f, where an officer, X, of company A sells stock • If e  f then X is guilty of insider trading

  18. Revisiting the Previous Problems • Parallel experiment • If e  f then changing what happens in e can affect what happens in f

  19. Concurrent Events • a || b iff (NOT (a  b)) & (NOT (b  a)) – Question? • (a || b) & (b || c) => (a || c) ?

  20. Using Event Diagrams to Understand Causality

  21. Logical Clocks • Goal of logical clock is – Assign each event a timestamp – If e  f then the timestamp of e should be less than that of f. – To solve this, each process maintains a logical clock cl • cl.j : clock value of process j • cl.m : clock value of message m • cl.a : clock value of event a

  22. Program for Logical Timestamps • Let a be a new event – If a is a local event at j • cl.j := cl.j + 1 • cl.a := cl.j – If a is a send event at j • cl.j := cl.j + 1 • cl.m := cl.j • cl.a := cl.j – If a is a receive of message m at j • cl.j := max(cl.j, cl.m) + 1 • cl.a := cl.j

  23. Properties of Logical Clocks • If a  b then cl.a < cl.b

  24. Proving Properties of Logical Clocks • Theorem: At any time, the following statement is true for all events (that have occurred in the system so far) – ∀ x, y :: x  y ⇒ cl.x < cl.y, – where x and y range over all the events, processes (latest event on the process) and messages (corresponding send event) • Proof by induction • Base case – No events created. Hence, trivially true – Show that whenever a new event is created

  25. Invariant • The predicate – a  b ⇒ cl.a < cl.b – Is an invariant of the logical timestamp program.

  26. Logical Timestamps • The time associated with an event is a pair, the clock and the process where the event occurred. • For event a at process j, the timestamp ts.a is – ts.a = <cl.a, j> Lexicographical comparison < x1, x2 > < <y1, y2> iff x1 < y1 ∨ ( (x1 = y1) ∧ (x2 < y2) )

  27. Observation about Logical Clocks • For any two distinct events a and b, either • ts.a < ts.b ∨ ts.b < ts.a • The event timestamps form a total order.

  28. So What? • Consider two events – An inside event, say e , that affects the company A – An event f, where an officer, X, of company A sells stock • Question – Is it possible that X is guilty of insider trading? • Case 1 – cl.e = 8, cl.f = 10 – Answer: • Case 2 – cl.e = 10, cl.f = 8 – Answer:

  29. Problem • Logical timestamps provide a partial information about causality. • Extending logical timestamps for complete knowledge of causality

  30. Accurate Causality Information • Desire – a  b  clock.a < clock.b • Can clock.a be an integer?

  31. Accurate Causality Information • To obtain accurate causality information, clock must consist of several integers – It turns out that accurate causality information requires clocks to consist of n values

  32. Vector Clocks • Each process maintains a vector vc – vc.j is the clock maintained by j – vc.j is an array • vc.j.k denotes the knowledge that j has about the clock of k => vc.j.j denotes the clock of j

  33. Updating Vector Clocks • Let a be a new event – If a is a send event at j • vc.j.j++ • vc.m := vc.j • vc.a := vc.j – If a is a receive of message m at j • vc.j := max(vc.j, vc.m) • vc.j.j++ • vc.a := vc.j

  34. Causality Checking with Vector Clocks • vc.a < vc.b iff – (Subject to requirement a  b iff vc.a < vc.b)

  35. Causality Checking with Vector Clocks • Suppose a is an event at process j and b is an event at process k – vc.a < vc.b iff

  36. Size of Vector Clocks • Our implementation requires clocks of size n – Can we do better?

  37. Lower bound on size of VC • Consider the network with n processes – Consider the following communication • Initial event on process j is a j • Each process j sends a message to everyone except (j-1) mod n • Each process receives all messages intended for it. – All receives are after all sends • Final event on process j is b j

  38. Lower bound on VC (continued) • Observations – a j+1 || b j – For j≠k • a k+1  b j

  39. • Suppose in contradiction, there is a way to implement vector clocks with k - vectors of reals, where k < n. • a j+1 || b j => V(a j+1 ) and V(b j ) are incomparable => V(a j+1 ) is larger than V(b j ) in some coordinate Denote this value by h(i) • h : {0,…,n - 1} → {0,…,k - 1}

  40. • h cannot be a one-to-one function – There exists j and k such that h(j) = j(k) • Let this value be r • Compare V(b j ), V(a j+1 ), V(b j ) and V(a k+1 ) – Evaluate with respect to element r

  41. Causal Delivery • Problem requirement – Given two messages m1 and m2 sent to the same process • If send(m1)  send(m2) • Then Delivery(m1)  Delivery(m2)

  42. Solving Causal Broadcast • Special case of causal delivery where all messages are broadcast in nature – Applications in checkpointing etc. • Variables – num.j.k = knowledge that j has about the number of messages sent by k • num.j.j = number of messages sent by j

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend