Vector clock explained

Vector clock should not be confused with Version vector.

A vector clock is a data structure used for determining the partial ordering of events in a distributed system and detecting causality violations. Just as in Lamport timestamps, inter-process messages contain the state of the sending process's logical clock. A vector clock of a system of N processes is an array/vector of N logical clocks, one clock per process; a local "largest possible values" copy of the global clock-array is kept in each process.

Denote

VCi

as the vector clock maintained by process

i

, the clock updates proceed as follows:[1]

i

, it updates

VCi[i]\leftarrowVCi[i]+1

.

Pi

receives a message

(m,VCj)

from

Pj

, it first increments its own logical clock in the vector by one

VCi[i]\leftarrowVCi[i]+1

and then updates its entire vector by setting

VCi[k]\leftarrowmax(VCi[k],VCj[k]),\forallk

.

History

Lamport originated the idea of logical Lamport clocks in 1978.[2] However, the logical clocks in that paper were scalars, not vectors. The generalization to vector time was developed several times, apparently independently, by different authors in the early 1980s.[3] At least 6 papers contain the concept.[4] The papers canonically cited in reference to vector clocks are Colin Fidge’s and Friedemann Mattern’s 1988 works,[5] [6] as they (independently) established the name "vector clock" and the mathematical properties of vector clocks.[3]

Partial ordering property

Vector clocks allow for the partial causal ordering of events. Defining the following:

VC(x)

denotes the vector clock of event

x

, and

VC(x)z

denotes the component of that clock for process

z

.

VC(x)<VC(y)\iff\forallz[VC(x)z\leVC(y)z]\land\existsz'[VC(x)z'<VC(y)z']

VC(x)

is less than

VC(y)

, if and only if

VC(x)z

is less than or equal to

VC(y)z

for all process indices

z

, and at least one of those relationships is strictly smaller (that is,

VC(x)z'<VC(y)z'

).

x\toy

denotes that event

x

happened before event

y

. It is defined as: if

x\toy

, then

VC(x)<VC(y)

Properties:

VC(a)<VC(b)

, then ¬

(VC(b)<VC(a))

VC(a)<VC(b)

and

VC(b)<VC(c)

, then

VC(a)<VC(c)

; or, if

a\tob

and

b\toc

, then

a\toc

Relation with other orders:

RT(x)

be the real time when event

x

occurs. If

VC(a)<VC(b)

, then

RT(a)<RT(b)

C(x)

be the Lamport timestamp of event

x

. If

VC(a)<VC(b)

, then

C(a)<C(b)

Other mechanisms

See also

External links

Notes and References

  1. Web site: Distributed Systems 3rd edition (2017). 2021-03-21. DISTRIBUTED-SYSTEMS.NET. en-US.
  2. Lamport . L. . Leslie Lamport. Time, clocks, and the ordering of events in a distributed system . 10.1145/359545.359563 . Communications of the ACM . 21 . 7 . 558–565. 1978 . 215822405 .
  3. Schwarz . Reinhard . Mattern . Friedemann . Detecting causal relationships in distributed computations: In search of the holy grail . Distributed Computing . March 1994 . 7 . 3 . 149–174 . 10.1007/BF02277859. 3065996 .
  4. Web site: Kuper . Lindsey . Who invented vector clocks? . decomposition ∘ al . en . 8 April 2023. The papers are (in chronological order):
    • Book: Fischer . Michael J. . Michael . Alan . Proceedings of the 1st ACM SIGACT-SIGMOD symposium on Principles of database systems - PODS '82 . Sacrificing serializability to attain high availability of data in an unreliable network . 1982 . 70 . 10.1145/588111.588124. 0897910702 . 8774876 .
    • Parker . D.S. . Popek . G.J. . Rudisin . G. . Stoughton . A. . Walker . B.J. . Walton . E. . Chow . J.M. . Edwards . D. . Kiser . S. . Kline . C. . Detection of Mutual Inconsistency in Distributed Systems . IEEE Transactions on Software Engineering . May 1983 . SE-9 . 3 . 240–247 . 10.1109/TSE.1983.236733. 2483222 .
    • Book: Wuu . Gene T.J. . Bernstein . Arthur J. . Proceedings of the third annual ACM symposium on Principles of distributed computing - PODC '84 . Efficient solutions to the replicated log and dictionary problems . 1984 . 233–242 . 10.1145/800222.806750. 0897911431 . 2384672 .
    • Strom . Rob . Yemini . Shaula . Optimistic recovery in distributed systems . ACM Transactions on Computer Systems . August 1985 . 3 . 3 . 204–226 . 10.1145/3959.3962. 1941122 . free .
    • Schmuck . Frank B. . Software clocks and the order of events in a distributed system . November 1985 . unpublished .
    • Book: Liskov . Barbara . Ladin . Rivka . Proceedings of the fifth annual ACM symposium on Principles of distributed computing - PODC '86 . Highly available distributed services and fault-tolerant distributed garbage collection . 1986 . 29–39 . 10.1145/10590.10593. 0897911989 . 16148617 .
    • Raynal . Michel . A distributed algorithm to prevent mutual drift between n logical clocks . Information Processing Letters . February 1987 . 24 . 3 . 199–202 . 10.1016/0020-0190(87)90186-4.
  5. Colin J.. Fidge. February 1988. Timestamps in message-passing systems that preserve the partial ordering. Proceedings of the 11th Australian Computer Science Conference (ACSC'88). 10. 1 . K. Raymond. 56–66 . 2009-02-13.
  6. Virtual Time and Global States of Distributed systems. Proc. Workshop on Parallel and Distributed Algorithms. Friedemann. Mattern . Cosnard . M. . Chateau de Bonas, France . October 1988 . Elsevier . 215–226.
  7. Book: Agarwal . Anurag . Garg . Vijay K. . Proceedings of the twenty-fourth annual ACM symposium on Principles of distributed computing . Efficient dependency tracking for relevant events in shared-memory systems . 17 July 2005 . 19–28 . 10.1145/1073814.1073818 . http://users.ece.utexas.edu/~garg/dist/agarwal-garg-DC.pdf . 21 April 2021 . Association for Computing Machinery. 1-58113-994-2 . 11779779 .
  8. Pozzetti . Tommaso . Kshemkalyani . Ajay D. . Resettable Encoded Vector Clock for Causality Analysis With an Application to Dynamic Race Detection . IEEE Transactions on Parallel and Distributed Systems . 1 April 2021 . 32 . 4 . 772–785 . 10.1109/TPDS.2020.3032293. 220362525 . free .
  9. Book: Kulkarni . Sandeep S . Appleton . Gabe . Nguyen . Duong . Proceedings of the 23rd International Conference on Distributed Computing and Networking . Achieving Causality with Physical Clocks . 4 January 2022 . 97–106 . 10.1145/3491003.3491009. 2104.15099 . 9781450395601 . 233476293 .