ordering and consistent cuts presented by chi h. ho

71
Ordering and Consistent Cuts Presented by Chi H. Ho

Post on 21-Dec-2015

218 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Ordering and Consistent Cuts Presented by Chi H. Ho

Ordering and Consistent Cuts

Presented by Chi H. Ho

Page 2: Ordering and Consistent Cuts Presented by Chi H. Ho

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

Leslie Lamport

Page 3: Ordering and Consistent Cuts Presented by Chi H. Ho

Introduction

• 2000 PODC Influential Paper Award• Outline of the paper: not in presented order

– Partial and Total Orderings– Logical and Physical Clocks– Clock and Strong Clock Conditions– Synchronize Physical Clocks

• Beyond…

Page 4: Ordering and Consistent Cuts Presented by Chi H. Ho

“Happened Before”

• a b: if– a and b are events in the same process and a

comes before b, or– a is the send event of some message, and b is

the receive event of the same message.

• Transitive:

(a b) & (b c) (a c)• Concurrent: (a b) & (b a).

Partial Ordering

Page 5: Ordering and Consistent Cuts Presented by Chi H. Ho

Examples

• q5 p4

• q2 q3

• p1 r3

• q2 // p2

• q2 // p3

Partial Ordering

Page 6: Ordering and Consistent Cuts Presented by Chi H. Ho

Logical Clock

• Clock Condition:

a,b:a b C(a) < C(b)

Partial Ordering Implementation

Page 7: Ordering and Consistent Cuts Presented by Chi H. Ho

Logical Clock

• Implementation Rules:– IR1:

• Each process Pi increments Ci between any two successive events.

– IR2:• If event a is the sending of a message m by process Pi,

then the message contains a timestamp Tm = Ci(a).

• Upon receiving a message m, process Pj sets Cj greater than or equal to its present value and greater than Tm.

Partial Ordering Implementation

Page 8: Ordering and Consistent Cuts Presented by Chi H. Ho

Examples

Partial Ordering Implementation

P0

P1

0

Page 9: Ordering and Consistent Cuts Presented by Chi H. Ho

Examples

Partial Ordering Implementation

P0

P1

0

0

Page 10: Ordering and Consistent Cuts Presented by Chi H. Ho

Examples

Partial Ordering Implementation

P0

P1

0

0

1

Page 11: Ordering and Consistent Cuts Presented by Chi H. Ho

Examples

Partial Ordering Implementation

P0

P1

0

0

1

1

Page 12: Ordering and Consistent Cuts Presented by Chi H. Ho

Examples

Partial Ordering Implementation

P0

P1

0

0

1

1 2

Page 13: Ordering and Consistent Cuts Presented by Chi H. Ho

Examples

Partial Ordering Implementation

P0

P1

0

0

1

1 2 3

[3]

Page 14: Ordering and Consistent Cuts Presented by Chi H. Ho

Examples

Partial Ordering Implementation

P0

P1

0

0

1

1 2 3

[3]

2

[2]

Page 15: Ordering and Consistent Cuts Presented by Chi H. Ho

Examples

Partial Ordering Implementation

P0

P1

0

0

1

1 2 3

[3]

2

[2]

4

Page 16: Ordering and Consistent Cuts Presented by Chi H. Ho

Examples

Partial Ordering Implementation

P0

P1

0

0

1

1 2 3

[3]

2

[2]

4

4

Page 17: Ordering and Consistent Cuts Presented by Chi H. Ho

Extended “Happened Before”

• a => b: iff– Ci(a) < Cj(b), or

– (Ci(a) = Cj(b)) & (Pi ≺ Pj)

Total Ordering

Page 18: Ordering and Consistent Cuts Presented by Chi H. Ho

Example Application

• Shared resource granting– Fixed number of processes– Single shared resource– Requirements:

I. Mutual Exclusive

II. Fair

III. Exhaustive

Total Ordering

Page 19: Ordering and Consistent Cuts Presented by Chi H. Ho

Example Application

• Solution: Distributed algorithm• Model:

– Channels are FIFO– Each process maintains a process queue

• Algorithm– Request: broadcast Tm:Pi request resource– Release: broadcast Tm:Pi release resource– Receive request: enqueue– Receive release: dequeue– Resource granted (local decision): Pi

• Tm:Pi request resource w/ Tm min• Pi has received from every process a msg timestamped later than Tm

• Note: – Can be generalized to solve Replicated State Machine!

Total Ordering

Page 20: Ordering and Consistent Cuts Presented by Chi H. Ho

Anomaly

Amazon.com[19]

Page 21: Ordering and Consistent Cuts Presented by Chi H. Ho

Anomaly

Amazon.com[19]

Page 22: Ordering and Consistent Cuts Presented by Chi H. Ho

Anomaly

Amazon.com[19] [7]

Page 23: Ordering and Consistent Cuts Presented by Chi H. Ho

Anomaly

Amazon.com[19]

[7]

Page 24: Ordering and Consistent Cuts Presented by Chi H. Ho

Anomaly

Amazon.com[19]

[7]

External event

Page 25: Ordering and Consistent Cuts Presented by Chi H. Ho

Strong Clock Condition

• S = {events in the system}

• S = S ⋃ {relevant external events}

is “happened before” for S

∀a,b ∈ S:

a b C(a) < C(b)

Avoid Anomaly

Page 26: Ordering and Consistent Cuts Presented by Chi H. Ho

Physical Clocks

• PC1: (drift rate bound)

∃ << 1 such that ∀i: |dCi(t)/dt – 1| <

• PC2: (drift bound)

i,j: |Ci(t) – Cj(t)| <

Page 27: Ordering and Consistent Cuts Presented by Chi H. Ho

Avoid Anomaly

< shortest msg transmission time• ∀i,j,t:

Ci(t+) – Cj(t) > 0

Physical Clocks

/(1-)

Amazon.com

ji

Cj(t) > Ci(t+)

>

Page 28: Ordering and Consistent Cuts Presented by Chi H. Ho

Implementation Rules

• IR1’: – For each i, if Pi does not receive a message at

physical time t, then Ci is differentiable at t and dCi(t)/dt > 0.

• IR2’:– (a) If Pi sends a message m at physical time t,

then m contains a timestamp Tm = Ci(t).– (b) Upon receiving a message m at time t’,

process Pj sets Cj(t’) equal to maximum (Cj(t’-0), Tm + m)

Physical Clocks

Page 29: Ordering and Consistent Cuts Presented by Chi H. Ho

Synchronize Physical Clocks

Physical Clocks

• Problem statement:– IR1’ and IR2’ are followed,– Message delay is bounded,– Clocks satisfied PC1,– Goal: PC2

• Algorithm:– Every seconds, a message is sent over every arc.

• Guarantees:– Clocks are synchronized after t0 + d d(2 + )

Page 30: Ordering and Consistent Cuts Presented by Chi H. Ho

Beyond…

• Shortcomings:– No gap-detection property– C(a) < C(b) ???– Bounds are not practical (So is PC!)

Page 31: Ordering and Consistent Cuts Presented by Chi H. Ho

Gap Detection Property

• Problem statement:– Given: a, b, C(a), C(b), C(a) < C(b), – Determine if c exists, where

C(a) < C(c) < C(b)?

Beyond…

Page 32: Ordering and Consistent Cuts Presented by Chi H. Ho

Another Strong Clock Condition

a b C(a) < C(b)

Beyond…

Page 33: Ordering and Consistent Cuts Presented by Chi H. Ho

What clock, then?

• Causal histories:

Beyond…

• Vector Clocks:

Page 34: Ordering and Consistent Cuts Presented by Chi H. Ho

More on Vector Clocks

Strong Clock ConditionConcurrentPair-wise InconsistentConsistent CutCountingGap Detection

Beyond…

Page 35: Ordering and Consistent Cuts Presented by Chi H. Ho

More on Vector Clocks

Strong Clock ConditionConcurrentPair-wise InconsistentConsistent CutCountingGap Detection, but…

Beyond…

X Weak Gap-Detection

Given a, b, can detect existence of c such that

(c a) & (c b)

Page 36: Ordering and Consistent Cuts Presented by Chi H. Ho

Reference

• O. Babaoglu and K. Marzullo. Consistent global states of distributed systems: Fundamental concepts and mechanisms. In Sape Mullender, editor, Distributed Systems, ch. 4, pages 55--96. Addison Wesley, 2nd ed., 1993. http://citeseer.ist.psu.edu/babaoglu93consistent.html

• Note: some materials in this paper are used to clarify a few concepts in the next paper.

Beyond…

Page 37: Ordering and Consistent Cuts Presented by Chi H. Ho

Distributed Snapshots: Determining Global States of Distributed Systems

K. Mani Chandy

Leslie Lamport

Page 38: Ordering and Consistent Cuts Presented by Chi H. Ho

Introduction

• Outline of the paper:– Motivation– Model– Algorithm– Correctness– Other issues

• Beyond…

Page 39: Ordering and Consistent Cuts Presented by Chi H. Ho

Motivation

• Capture the global state of a system.

• Really?True global state:

Impossible!!!

p1

e11 e1

2 e13 e1

4 e15 e1

6

p2e2

1 e22 e2

3 e24 e2

5

Page 40: Ordering and Consistent Cuts Presented by Chi H. Ho

p1

e11 e1

2 e13 e1

4 e15 e1

6

p2e2

1 e22 e2

3 e24 e2

5

Motivation

• Capture the global state of a system.

• Really?These are what

can be done

Are they useful?

Page 41: Ordering and Consistent Cuts Presented by Chi H. Ho

p1

e11 e1

2 e13 e1

4 e15 e1

6

p2e2

1 e22 e2

3 e24 e2

5

Motivation

• Capture the global state of a system.

• Useful?

Equivalent!

p1

e11 e1

2 e13 e1

4 e15 e1

6

p2e2

1 e22 e2

3 e24 e2

5

Page 42: Ordering and Consistent Cuts Presented by Chi H. Ho

p1

e11 e1

2 e13 e1

4 e15 e1

6

p2e2

1 e22 e2

3 e24 e2

5

Motivation

• Capture the global state of a system.

• Useful?

Consistent, but not happens in reality.

p1

e11 e1

2 e13 e1

4 e15 e1

6

p2e2

1 e22 e2

3 e24 e2

5

Page 43: Ordering and Consistent Cuts Presented by Chi H. Ho

p1

e11 e1

2 e13 e1

4 e15 e1

6

p2e2

1 e22 e2

3 e24 e2

5

Motivation

• Capture the global state of a system.

• Useful?

Not even consistent!

p1

e11 e1

2 e13 e1

4 e15e1

6

p2e2

1 e22 e2

3 e24 e2

5

Page 44: Ordering and Consistent Cuts Presented by Chi H. Ho

Motivation

• Capture the global state of a system.

• Useful? Yes:– To detect stable

properties of a system:y(S) y(S’)

for all S’ reachable from S.

– E.g.: • “computation has

terminated,” • “the system is

deadlocked,”• “all tokens in a token

ring have disappeared.”

Page 45: Ordering and Consistent Cuts Presented by Chi H. Ho

Model

A distributed system

• A distributed system (on the right).

• A global state = set of processes’ and channels’ states.

• Event:– atomic– e = <p, S, S’, m,

c>• Computation:

– seq =(ei: 0 i n)

– Si+1 = next(Si, ei)

• Channels’ assumptions:– Singly directed– FIFO– Asynchronous– Error free– Infinite buffer

Page 46: Ordering and Consistent Cuts Presented by Chi H. Ho

Algorithm

• Invoker: behave as if receiving a marker from a virtual node.• Receiving rule for process q receiving a marker along channel

c:if q has not recorded its state then

begin q records its state; q records the state c as the empty sequenceend

else q records the state of c as the sequence of messages received along c after q’s state was recorded and before q received the marker along c.

• Sending rule for a process p: for each outgoing channel c:p sends one marker along c after p records its

state and before p sends further messages along c.

Page 47: Ordering and Consistent Cuts Presented by Chi H. Ho

Illustration

• Next 14 slides, courtesy of Professor Birman.

Page 48: Ordering and Consistent Cuts Presented by Chi H. Ho

Chandy/Lamport

p

qr

s

t

u

v

w

xy

z

A network

Page 49: Ordering and Consistent Cuts Presented by Chi H. Ho

Chandy/Lamport

p

qr

s

t

u

v

w

xy

z

A network

I want to start a

snapshot

Page 50: Ordering and Consistent Cuts Presented by Chi H. Ho

Chandy/Lamport

p

qr

s

t

u

v

w

xy

z

A network

p records local state

Page 51: Ordering and Consistent Cuts Presented by Chi H. Ho

Chandy/Lamport

p

qr

s

t

u

v

w

xy

z

A network

p starts monitoring incoming channels

Page 52: Ordering and Consistent Cuts Presented by Chi H. Ho

Chandy/Lamport

p

qr

s

t

u

v

w

xy

z

A network

“contents of channel p-y”

Page 53: Ordering and Consistent Cuts Presented by Chi H. Ho

Chandy/Lamport

p

qr

s

t

u

v

w

xy

z

A network

p floods message on outgoing channels…

Page 54: Ordering and Consistent Cuts Presented by Chi H. Ho

Chandy/Lamport

p

qr

s

t

u

v

w

xy

z

A network

Page 55: Ordering and Consistent Cuts Presented by Chi H. Ho

Chandy/Lamport

p

qr

s

t

u

v

w

xy

z

A network

q is done

Page 56: Ordering and Consistent Cuts Presented by Chi H. Ho

Chandy/Lamport

p

qr

s

t

u

v

w

xy

z

A network

q

Page 57: Ordering and Consistent Cuts Presented by Chi H. Ho

Chandy/Lamport

p

qr

s

t

u

v

w

xy

z

A network

q

Page 58: Ordering and Consistent Cuts Presented by Chi H. Ho

Chandy/Lamport

p

qr

s

t

u

v

w

xy

z

A network

q

zs

Page 59: Ordering and Consistent Cuts Presented by Chi H. Ho

Chandy/Lamport

p

qr

s

t

u

v

w

xy

z

A network

q

v

z

x

u

s

Page 60: Ordering and Consistent Cuts Presented by Chi H. Ho

Chandy/Lamport

p

qr

s

t

u

v

w

xy

z

A network

q

v

w

z

x

u

s

y

r

Page 61: Ordering and Consistent Cuts Presented by Chi H. Ho

Chandy/Lamport

pq

r

s

t

u

v

w

xy

z

A snapshot of a network

q

x

u

s

v

r

t

w

p

y

z

Done!

Page 62: Ordering and Consistent Cuts Presented by Chi H. Ho

Correctness

• Consistency

• Termination

Page 63: Ordering and Consistent Cuts Presented by Chi H. Ho

Consistency

• m is recorded iff so is send(m):– sender’s state recording and marker

sending are done atomically.• m is not recorded more than once:

– if channel is recorded before receiver, it will be empty.

– if channel is recorded after receiver, none of the in-channel messages will be recorded as the receiver’s state.

Correctness:

Page 64: Ordering and Consistent Cuts Presented by Chi H. Ho

Termination

• Assumptions:– L1: no marker remains forever in a channel.– L2: processes’ states are recorded in finite time.

• Every process either spontaneously records its state, or there is a path from such a process.

• Every channel is flushed by a marker after the sender records its state.

Correctness:

Page 65: Ordering and Consistent Cuts Presented by Chi H. Ho

Remained Issues

• Property of recorded state:Si --> S* --> Sf

• Stable detection:– Stable property:

• y(Si) definite• definite y(Sf)

– Algorithm:begin

record a global state S*;definite := y(S*)

end.

Page 66: Ordering and Consistent Cuts Presented by Chi H. Ho

Beyond…

• Channels’ assumptions:–Singly directed–FIFO–Asynchronous–Error free–Infinite buffer

Page 67: Ordering and Consistent Cuts Presented by Chi H. Ho

Non-FIFO

• What is FIFO for?–Separate messages between

before-snapshot and after-snapshot.

• A snapshot counter piggybacked on messages would do just fine!

Beyond:

Page 68: Ordering and Consistent Cuts Presented by Chi H. Ho

Beyond…

• Channels’ assumptions:–Singly directed–FIFO–Asynchronous–Error free–Infinite buffer

Messages can be corrupted/duplicated

Messages can be dropped

Page 69: Ordering and Consistent Cuts Presented by Chi H. Ho

Unreliable channels

• How to deal with corruption?– Checksum/ECC; reduced to drop.

• How to deal with duplication?– Message ID

• How to deal with dropping?– Channel states are not needed

anymore.– Markers indicate completion.

Beyond:

Page 70: Ordering and Consistent Cuts Presented by Chi H. Ho

Even More Aggressive…

• Don’t want to piggyback!• Step 1: no piggybacking:

– Block all messages sent after recording local state and before receiving marker from all neighbors.

• Step 2: no blocking, min piggybacking– Blocked messages are sent with

piggybacked snapshot info.

Beyond:

Page 71: Ordering and Consistent Cuts Presented by Chi H. Ho

Conclusion

• Two influential papers.• Much work built upon these results.• Can be improved significantly when

being adopted to particular systems.

• Additional comments/suggestions?