Time and global states Time and global states Jerry Eriksson, VT-01 - - PDF document

time and global states time and global states
SMART_READER_LITE
LIVE PREVIEW

Time and global states Time and global states Jerry Eriksson, VT-01 - - PDF document

Time and global states Time and global states Jerry Eriksson, VT-01 Jerry Eriksson, VT-01 Important issues in distributed Important issues in distributed systems systems Timestamping Timestamping files, transactions files,


slide-1
SLIDE 1

1

Time and global states Time and global states

Jerry Eriksson, VT-01 Jerry Eriksson, VT-01

Important issues in distributed systems Important issues in distributed systems

Timestamping

Timestamping

files, transactions

files, transactions

Algorithms depend upon clock

Algorithms depend upon clock synchronization synchronization

Space and context is beyound the scope of

Space and context is beyound the scope of this book (belongs to mobile computing) this book (belongs to mobile computing)

Today Today

Physical clocks that can be approximately

Physical clocks that can be approximately synchronized using message passing synchronized using message passing

Logical clocks

Logical clocks

Algorithms whose purpose is to capture

Algorithms whose purpose is to capture global states of distributed systems as they global states of distributed systems as they execute execute

slide-2
SLIDE 2

2

Physical clocks Physical clocks

Clocks

Clocks

Clock skew and clock drift

Clock skew and clock drift

Coordinated Universial time

Coordinated Universial time

International standard. Radio waves. GPS!

International standard. Radio waves. GPS!

Network

Synchronizing physical clocks Synchronizing physical clocks

External sources

External sources

External synchronization

External synchronization

Internal synchronization

Internal synchronization

Clocks does not have to be accurate to be

Clocks does not have to be accurate to be correct correct

Easy in synchronous systems

Easy in synchronous systems

Christian´s method for synchronizing clocks in intranets Christian´s method for synchronizing clocks in intranets

Time server is used. Uses UTC

Time server is used. Uses UTC

Round-trip delay must be sufficiently short

Round-trip delay must be sufficiently short compared to accurary compared to accurary

mr mt p Time server,S

slide-3
SLIDE 3

3

Cristian’s method Cristian’s method

The client asks the server

The client asks the server

The server answer in a message

The server answer in a message

Minimum transmission time

Minimum transmission time

Accuracy in the interval

Accuracy in the interval

t+min, t + tround - min

t+min, t + tround - min

Drawback: a single server can fail

Drawback: a single server can fail

The Berkeley algorithm The Berkeley algorithm

A coordinatior computer is chosen as

A coordinatior computer is chosen as master, which poll the other computers master, which poll the other computers (slaves). (slaves).

The slaves sends back their clocks

The slaves sends back their clocks

Fault-tolerant average is computed and sent

Fault-tolerant average is computed and sent back to the slaves. back to the slaves.

A new master can be chosen if the current

A new master can be chosen if the current

  • nes chrashes.
  • nes chrashes.

The Network Time Protocol -

  • n the internet

The Network Time Protocol -

  • n the internet

Provide a service enabling clients across the

Provide a service enabling clients across the internet to be synchronized accurately internet to be synchronized accurately

Provide a reliable service that can survive

Provide a reliable service that can survive lengthy losses of connectivity lengthy losses of connectivity

Enable clients to resynchronize sufficiently

Enable clients to resynchronize sufficiently frequently to offset the rates of drift found frequently to offset the rates of drift found in most computers in most computers

Provide protection against interference

Provide protection against interference

slide-4
SLIDE 4

4

The Network Time Protocol - focus on the internet The Network Time Protocol - focus on the internet

Based on virtually hierarcial network of

Based on virtually hierarcial network of servers servers

Primary server direct connected to UTC.

Primary server direct connected to UTC.

Lowest level (leaf) is the users workstation

Lowest level (leaf) is the users workstation

1 2 3 2 3 3

Note: Arrows denote synchronization control, numbers denote strata.

NTP NTP

Fault-tolerant, re-building possible

Fault-tolerant, re-building possible

Multicast mode, high-speed LAN

Multicast mode, high-speed LAN

Procedure-call mode, similar to Chistian’s

Procedure-call mode, similar to Chistian’s algorithm algorithm

Symmetric mode

Symmetric mode

Uses UDP

Uses UDP

NTP NTP

Ti Ti-1 Ti-2 Ti- 3 Server B Server A Time m m' Time

slide-5
SLIDE 5

5

Logical time and logical clocks Logical time and logical clocks

Physical clocks cannot be used to order

Physical clocks cannot be used to order events processes at different computers. events processes at different computers.

Two intuitive points

Two intuitive points

If two events occured at the same process, then

If two events occured at the same process, then they occured in the order in which the process they occured in the order in which the process

  • bserved them.
  • bserved them.

The event of sending occured before the

The event of sending occured before the receiving the message receiving the message

Happend-before relations Happend-before relations

1: x->y

1: x->y

2:send(m) -> receive(m)

2:send(m) -> receive(m)

3: x->y and y->z, imply x->z

3: x->y and y->z, imply x->z

p1 p2 p3 a b c d e f m1 m2 Physical time

Logical clocks Logical clocks

Software counter.Time-stamp denoted by L.

Software counter.Time-stamp denoted by L.

HB-relation

HB-relation

LC1: Li is incremented before each event is

LC1: Li is incremented before each event is issued at p issued at pi; L ; Li = L = Li + 1 + 1

LC2a: When p

LC2a: When pi sends sends m, it piggybacks on , it piggybacks on m the the value, t = L value, t = L

i.

LC2b: On receiving (m, t), p

LC2b: On receiving (m, t), p

j computes L

computes Lj = = max(L max(Lj, t)+1 , t)+1

Observe L(b) > L(e), but b||e.

Observe L(b) > L(e), but b||e.

slide-6
SLIDE 6

6

Logical clocks Logical clocks

a b c d e f m1 m2 2 1 3 4 5 1 p1 p2 p3 Physical time

Totally ordered logical clocks

Totally ordered logical clocks

Use identifiers of the processes

Use identifiers of the processes

Vector clocks Vector clocks

Create totally ordered on eventes

Create totally ordered on eventes

Use a vector

Use a vector

Four rules

Four rules

Compare vector timestamps

Compare vector timestamps

More expensive

More expensive

Vector clocks Vector clocks

a b c d e f m1 m2 (2,0,0) (1,0,0) (2,1,0) (2,2,0) (2,2,2) (0,0,1) p1 p2 p3 Physical time

slide-7
SLIDE 7

7

Global states Global states

Distributed garbage collection

Distributed garbage collection

Distributed deadlock detection

Distributed deadlock detection

Distributed termination detection

Distributed termination detection

Distributed debugging

Distributed debugging

Global states; examples Global states; examples

p2 p1 message garbage object

  • bject

reference

  • a. Garbage collection

p 2 p1 wait-for wait-for

  • b. Deadlock

p2 p1 activate passive passive

  • c. Termination

Global states and consistent cuts Global states and consistent cuts

Essential problem: Absence of global time

Essential problem: Absence of global time

Construct a meaningful global state, using

Construct a meaningful global state, using local state information local state information

slide-8
SLIDE 8

8

Global states and consistent cuts Global states and consistent cuts

m1 m2 p1 p2 Physical time e1 Consistent cut Inconsistent cut e 1

1

e 1

2

e 1

3

e 2 e 2

1

e 2

2

Definitons Definitons

Run: total ordering of all events in a global

Run: total ordering of all events in a global history that is consistent with each local history that is consistent with each local history history

Linearization: Run + consitent with HB-

Linearization: Run + consitent with HB- relation relation

Predicate: Once ’true’, always ’true’

Predicate: Once ’true’, always ’true’

’Snap-shot’-algorithm ’Snap-shot’-algorithm

Record a set of global state that are

Record a set of global state that are

  • consistent. Assumes that
  • consistent. Assumes that

neither channels nor processes fail

neither channels nor processes fail

channels are unidirectional and provide FIFO-ordering

channels are unidirectional and provide FIFO-ordering message delivery message delivery

processes strongly connected

processes strongly connected

any process may initiate a global snapshot at any time

any process may initiate a global snapshot at any time

the process may continue their execution and send and

the process may continue their execution and send and receive normal messages while the snapshot takes place receive normal messages while the snapshot takes place

slide-9
SLIDE 9

9

Characterising the observered state Characterising the observered state

Consistent cuts are ensured

Consistent cuts are ensured

Detecting stable predictions

Detecting stable predictions

Sinit Sfinal Ssnap actual execution e 0,e1,... recording recording begins ends pre-snap: e '0,e'1,...e'R-1 post-snap: e ' R,e'R+1 ,...

The algorithm The algorithm

Each process records its state and also for each incoming

Each process records its state and also for each incoming channel a set of messages sent to it. channel a set of messages sent to it.

The process records, for each channel, any messages that

The process records, for each channel, any messages that arrived after it records its state and before the sender arrived after it records its state and before the sender recorded its own state. recorded its own state.

Message may belong to a channel

Message may belong to a channel

’Snap-shot algorithm’ ’Snap-shot algorithm’

Marker receiving rule for process pi On p

i’s receipt of a marker message over channel c:

if (pi has not yet recorded its state) it records its process state now; records the state of c as the empty set; turns on recording of messages arriving over other incoming channels; else pi records the state of c as the set of messages it has received over c since it saved its state. end if Marker sending rule for process pi After pi has recorded its state, for each outgoing channel c: pi sends one marker message over c (before it sends any other message over c).

slide-10
SLIDE 10

10 10

Example Example

p 1 p 2 c 2 c 1 account widgets $1000 (none) account widgets $50 2000

  • Trade in widgets

Trade in widgets

Example Example

p1 p2 (empty) <$1000, 0> <$50, 2000> (empty) c2 c1

  • 1. Global state S 0
  • 2. Global state S 1
  • 3. Global state S 2
  • 4. Global state S 3

p1 p2 (Order 10, $100), M <$900, 0> <$50, 2000> (empty) c2 c1 p1 p2 (Order 10, $100), M <$900, 0> <$50, 1995> (five widgets) c2 c1 p1 p2 (Order 10, $100) <$900, 5> <$50, 1995> (empty) c2 c1 (M = marker message)

Distributed debugging Distributed debugging

Transitory state occurred in an actual execution.

Transitory state occurred in an actual execution.

Marzullo and Neiger: centralized algorithm: A monitor,

Marzullo and Neiger: centralized algorithm: A monitor,

  • utside the system, collects states and assembles globally
  • utside the system, collects states and assembles globally

consistent states (GCS) consistent states (GCS)

Definitely true: For all linearization L of H there is a GCS

Definitely true: For all linearization L of H there is a GCS through L passes such that the predicate is true. through L passes such that the predicate is true.

Possibly true: There is a CGS through which an L of H

Possibly true: There is a CGS through which an L of H passes such that the predicate is true. passes such that the predicate is true.

slide-11
SLIDE 11

11 11

Now the algorithm, ... Now the algorithm, ...

The process states are collected. (queues for

The process states are collected. (queues for all processes) all processes)

The monitor extracts consistent global

The monitor extracts consistent global

  • states. (using vector clocks)
  • states. (using vector clocks)

The monitor evaluates possibly and

The monitor evaluates possibly and definitely in both asynchronous and definitely in both asynchronous and (synchronous) systems (synchronous) systems

Observing consistent global states Observing consistent global states

m

1

m2 p1 p2 Physical time Cut C1 (1,0) (2,0) (4,3) (2,1) (2,2) (2,3) (3,0) x1= 1 x1= 100 x1= 105 x2= 100 x2= 95 x2= 90 x1= 90 Cut C2

The lattice The lattice

Sij= global state after i events at process 1 and j events at process 2 S00 S10 S20 S21 S30 S31 S32 S22 S23 S33 S43 Level 0 1 2 3 4 5 6 7

slide-12
SLIDE 12

12 12

Evaluating possibly Evaluating possibly Evaluating definitely Evaluating definitely

F = (φ(S) = False); T = (φ(S ) = True) ? – Level 0 1 2 3 4 5 F F F F T F