distributed snapshot

29
Distributed Snapshot

Upload: emlyn

Post on 06-Jan-2016

23 views

Category:

Documents


4 download

DESCRIPTION

Distributed Snapshot. -- How many messages are in transit on the internet? --What is the global state of a distributed system of N processes? How do we compute these?. Think about these. One-dollar bank. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Distributed Snapshot

Distributed Snapshot

Page 2: Distributed Snapshot

Think about these

-- How many messages are in transit

on the internet?

-- What is the global state of a distributed

system of N processes?

How do we compute these?

Page 3: Distributed Snapshot

One-dollar bank

0

1

2

(0,1)

(1,2)(2,0)

Let a $1 coin circulate in a network of a million banks.

How can someone count the total $ in circulation? If

not counted “properly,” then one may think the total $

in circulation to be one million.

Page 4: Distributed Snapshot

Importance of snapshots

Major uses in

- deadlock detection

- termination detection

- rollback recovery

- global predicate

computation

Page 5: Distributed Snapshot

Consistent cut

(a ∈ C) ⋀ (b a) ≺ ⇒ b ∈ C

If this is not true, then the cut C is inconsistent

A cut is a set of events. If a cut C is consistent then

time

Page 6: Distributed Snapshot

Consistent snapshot

The set of states immediately following the events

(actions) in a consistent cut forms a consistent

snapshot of a distributed system.

• A snapshot that is of practical interest is the most

recent one. Let C1 and C2 be two consistent cuts

and C1 ⊂ C2. Then C2 is more recent than C1.

• Analyze why certain cuts in the one-dollar bank are

inconsistent.

Page 7: Distributed Snapshot

Consistent snapshot

How to record a consistent snapshot? Note that

1. The recording must be non-invasive.

2. Recording must be done on-the-fly.

You cannot stop the system.

Page 8: Distributed Snapshot

Chandy-Lamport Algorithm

Works on a

(1) strongly connected graph

(2) each channel is FIFO.

An initiator initiates the

algorithm by sending out a

marker ( )

Page 9: Distributed Snapshot

White and red processes

Initially every process is white.

When a process receives a marker,

it turns red if it has not already done so.

Every action by a process, and every

message sent by a process gets the

color of that process.

Page 10: Distributed Snapshot

Two steps

Step 1. In one atomic action, the initiator (a) Turns red (b) Records its own state (c) sends a marker along all outgoing channels

Step 2. Every other process, upon receiving a marker for the first time (and before doing anything else) (a) Turns red (b) Records its own state (c) sends markers along all outgoing channels

The algorithm terminates when (1) every process turns red, and (2) Every process has received a marker through each incoming channel.

Page 11: Distributed Snapshot

Why does it work?

Lemma 1. No red message is received in a white action.

Page 12: Distributed Snapshot

Why does it work?

Theorem. The global state recorded by Chandy-Lamport algorithm is equivalent to the ideal snapshot state SSS.

Hint. A pair of actions (a, b) can be scheduled in any order, if there is no causal order between them, so (a; b) is equivalent to (b; a)

SSSEasy conceptualization of the snapshot state

All white All red

Page 13: Distributed Snapshot

Why does it work?

Let an observer observe the following actions:

w[i] w[k] r[k] w[j] r[i] w[l] r[j] r[l] … w[i] w[k] w[j] r[k] r[i] w[l] r[j] r[l] … [Lemma 1]w[i] w[k] w[j] r[k] w[l] r[i] r[j] r[l] … [Lemma 1]w[i] w[k] w[j] w[l] r[k] r[i] r[j] r[l] … [done!]

Recorded state

Page 14: Distributed Snapshot

Example 1: Count the tokens

Let us verify that Chandy-Lamport snapshot algorithm correctly counts

the tokens circulating in the system

A

B

C

How to account for the channel states? Use sent and received variables for each process.

token no token

token

token

no token

no token

A

B

C

no token

no token

token

Are these consistent cuts?

1

2

3

Page 15: Distributed Snapshot

Example 2: Communicating State Machines

ch1

ch2

i j

up

down

up

state machine

i

state machine

j

send

M

send

M'

down

global state i ch1 j ch2

S0 down φ down φ

1 S up M down φ

2 S up M up M'

3 S down M up φ

receive

M'

receive

M

Page 16: Distributed Snapshot

Something unusual

Let machine i start Chandy-Lamport snapshot before it

has sent M along ch1. Also, let machine j receive the

marker after it sends out M’ along ch2. Observe that

the snapshot state is

down ∅ up M’

Doesn’t this appear strange? This state was never

reached during the computation!

Page 17: Distributed Snapshot

Understanding snapshot

S0

S1

i sends M

j sends M'

j receives M

j sends M'i receives M'

S1'

S2

S2'

i sends M

j receives M

i receives M'

i receives M' j receives M

S3

S0

S3'

recorded

state SSS

Page 18: Distributed Snapshot

Understanding snapshot

The observed state is a feasible state that is reachable

from the initial configuration. It may not actually be visited

during a specific execution.

The final state of the original computation is always

reachable from the observed state.

Page 19: Distributed Snapshot

Discussions

What good is a snapshot if that state has never been visited by the system?

- It is relevant for the detection of stable predicates.

- Useful for checkpointing.

Page 20: Distributed Snapshot

Discussions

What if the channels are not FIFO?

Study how Lai-Yang algorithm works. It does not use any marker

LY1. The initiator records its own state. When it needs to send a

message m to another process, it sends a message (m, red).

LY2. When a process receives a message (m, red), it records its state

if it has not already done so, and then accepts the message m.

Question 1. Why will it work?

Question 1 Are there any limitations of this approach?

Page 21: Distributed Snapshot

Food for thought

Distributed snapshot = distributed read.

Distributed reset = distributed write

How difficult is distributed reset?

Page 22: Distributed Snapshot

Distributed debugging(Marzullo and Neiger, 1991)

observer

Distributed system

e, VC(e)

Page 23: Distributed Snapshot

Distributed debugging

Page 24: Distributed Snapshot

Distributed debugging

Possibly ϕ: At least one consistent global state S is reachable from the initial global state, such that φ(S) = true.

Definitely ϕ: All computations pass through some consistent global state S such that φ(S) = true.

Never ϕ: No computation passes through some consistent global state S such that φ(S) = true.

Definitely ϕ Possibly ϕ ⇒

Page 25: Distributed Snapshot

Examples

ϕ = x+y =12 (true at S21) Possibly ϕ

ϕ = x+y > 15 (true at S32) Definitely ϕ

ϕ = x=y=5 (true at S40 and S22) Never ϕ

*Neither S40 and S22 is a consistent state*

Page 26: Distributed Snapshot

Global State Collection

Page 27: Distributed Snapshot

Global state collection

Some applications

- computing network topology

- termination detection

- deadlock detection

Chandy-Lamport algorithm does a partial job. Each process

generates a fragment of the global state, but these pieces have

to be “stitched together” to form a global state.

Page 28: Distributed Snapshot

A simple exercise

Once the pieces of a consistent

global state become available,

consider collecting the global state via

all-to-all broadcast

At the end, each process

will compute a set V, where

V= {s(i): 0 ≤ i ≤ N-1 }

i

k

j

l

s(i) s(j)

s(k) s(l)

Page 29: Distributed Snapshot

All-to-all broadcast

V.iW.i

V.kW.k

(i,k)

Acts like a “pump”

Assume that the topology is a strongly connected graph

V.jW.j

(j,i)