---
# System prepended metadata

title: version vector

---

# version vector


https://www.youtube.com/watch?v=x-D8iFU1d-o&ab_channel=MartinKleppmann

![](https://i.imgur.com/LPyoGJs.png)

![](https://i.imgur.com/Y650jP9.png)

### lamport clock


![](https://i.imgur.com/NmOSGWK.png)

* each node have it own time T
* each event on each node(receiving/send) update T=T+1
* send message with this T 
* when get message from other's node, update the local T = max(local T, message T)

![](https://i.imgur.com/alxiizV.png)

only rule out b happen before a,
the situation might be  
1. a happen before b
2. a and b concurrent

![](https://i.imgur.com/loFfrUj.png)

### lamport example

![](https://i.imgur.com/0iffgeM.png)

a send with t=2 
b receive get t=2+1=3
b send message with t++(t=4) to c
c receive message with t=t+1

lamport timestamp with node can assgin particular event

ex. A(2) as send message to B
B(4) send message to C
C(5) receive message from b

![](https://i.imgur.com/xTgZuII.png)

* N(a) N(b) ordering the nodes priority, seems nothing to do with Lamport clock....

* given L(a)<L(b), we cant judge a->b or a||b(concurrent)

---
### vector clock

lamport clock cant diff 1. a,b concurrent 2. a/b has casuality.


![](https://i.imgur.com/M12dC61.png)


![](https://i.imgur.com/OkZaPhC.png)



![](https://i.imgur.com/DZQhG7o.png)


---
### vector clock example


![](https://i.imgur.com/jWFqqQq.png)

strict equal for 3rd: there must be one time diff 

4th: incomparable


![](https://i.imgur.com/G4tA3vS.png)

sets of events

vector clock A here correspond to (the set of events of A) plus (all of the events that happened before A)

and vertor clock B correspond (the set events of B) plus (all of the events that happened before B)

the less than recall relationship correspond to subset relationship on those two sets of event

given a nice way of reasoning about what the vectors actually mean

![](https://i.imgur.com/NDfSEkr.png)

vector clock given a bidirectional relationship

3rd: the vector clock are concurrent, the vector is incomparable.

