Distributed computing “Event synchronization and global states” Mathieu Delalandre University of Tours, Tours city, France
[email protected]
1
Event synchronization and global states 1. Introduction 2. Logical time 2.1. Logical clocks 2.2. Vector clocks 2.3. Efficient implementation of vector clocks 3. Global states and snapshot recording algorithms 3.1. Global states 3.2. The snapshot algorithm for FIFO channel
2
Introduction Two approaches to synchronize processes, with clock or event: Clock synchronization deals with the exchange of clock values between computers in a distributed system with message passing, to correct clock drift. Clock synchronization protocols can maintain time accurate to a few tens of milliseconds.
Event synchronization: synchronization doesn’t need to be time-based, it could be solved by ordering events of processes using logical clock (i.e. a mechanism for capturing chronological and causal relationships in a distributed system). P1 a
t2+∆t
c
i
P2 P1
P2
query computer 1
d
f
g
h
P3 computer 2
t2:
time of computer 2
∆t:
mean time to transmit a message
b P1,P2,P3 are processes a,b,c … are events
e
j time t
While processing, the rate of occurrence of events is important with short execution time. Clock synchronization protocols are then not fully adequate to capture the causality relations in distributed systems.
3
Event synchronization and global states 1. Introduction 2. Logical time 2.1. Logical clocks 2.2. Vector clocks 2.3. Efficient implementation of vector clocks 3. Global states and snapshot recording algorithms 3.1. Global states 3.2. The snapshot algorithm for FIFO channel
4
Logical time “Logical clocks” (1) 1
2
a
c
7
Logical clocks are a mechanism for capturing chronological and causal relationships between processes through the happens-before relation.
any single event
Happens-before relation is a relation between two events, such that one event should happen before the other one:
message event
g
P2 h
1
2
6
b
e
j
P3
L3 (for P3)
concerned process event
∅
0
0
0
a
1=0+1
0
0
action
b
1
0
1=0+1
c
2=1+1
0
1
d
2
3=max(0,2)+1
1
e
2
3
2=1+1
f
2
4=max(3,2)+1
2
g
2
5=4+1
2
h
2
6=5+1
2
i
7=max(6,2)+1
6
2
j
7
6
6=max(5,2)+1
Their event counters Li and Lj
concerned processes
Pj →
f
i
L2 (for P2)
Lj
a
d
6
L1 (for P1)
Li
Pi
5
Events
Two distant processes Pi and Pj
do Li = Li+1
4
time
Pj
a
3
1,2,3 … are counter values a,b,c … are events
Pi
Pi (could be Pj)
processes
P1
b
Pi sends a message to Pj
Pj receives the message of Pi
do Li = Li+1, then send Li to Pj
do Lj=max(Li,Lj), then Lj = Lj+1
events
actions
Logical time “Logical clocks” (2) Logical clocks are a mechanism for capturing chronological and causal relationships between processes through the happens-before relation.
any single event
Happens-before relation is a relation between two events, such that one event should happen before the other one: Pi
Pj
Two distant processes Pi and Pj
Li
Lj
Their event counters Li and Lj
Pi (could be Pj) a do Li = Li+1
message event
Pi a
Strict partial order: (1) if events a, b occur on the same process, with a preceding b, we have a → b (2) if event a is the sending of a message and event b its reception, we have a → b Transitivity: for all events a, b, c, if a → b and b → c then we have a → c
concerned process event
Irreflexivity: for an event a, we have a ↛ a i.e. an irreflexivity is a binary relation on a set where no element is related to itself. e.g. is the "greater than" relation (x>y) on the real numbers
action
Antisymmetry: for all events a, b, if a → b then b ↛ a concerned processes
Pj →
Baseline properties
b
Pi sends a message to Pj
Pj receives the message of Pi
do Li = Li+1, then send Li to Pj
do Lj=max(Li,Lj), then Lj = Lj+1
events
actions 6
Logical time “Logical clocks” (3) Consistency, concurrency and ordering properties
Happens-before relation is a relation between two events, such that one event should happen before the other one:
Consistency property: for all events a, b, if a → b then L(a) < L(b)
any single event
Logical clocks are a mechanism for capturing chronological and causal relationships between processes through the happens-before relation.
No strong consistency: the converse of consistency property is not true, if L(a) < L(b) we have a → b or a↛b
Pi
Pj
Two distant processes Pi and Pj
Li
Lj
Their event counters Li and Lj
Concurrency: if L(a) = L(b) then a||b (a and b are concurrent)
concerned process event
Total ordering: events that occur at the same logical time are concurrent. They can be ordered using any arbitrary criterion such as process identifiers. The lower the process identifier in the ranking, the higher the priority.
Pi (could be Pj) a
action
do Li = Li+1 Pi
message event
Mapping function: L() is a mapping function such a L(a) returns the logical clock value of event a
a
concerned processes
Pj →
b
Pi sends a message to Pj
Pj receives the message of Pi
do Li = Li+1, then send Li to Pj
do Lj=max(Li,Lj), then Lj = Lj+1
events
a is an event of Pi, b is an event of Pj i, j are process identifiers of Pi, Pj a ordered before b (for short a < b) if L(a) < L(b) OR (a||b AND i