Vector clock
A vector clock is a
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 as the vector clock maintained by process , the clock updates proceed as follows:[1]
- Initially all clocks are zero.
- Each time a process experiences an internal event, it increments its own logical clock in the vector by one. For instance, upon an event at process , it updates .
- Each time a process sends a message, it increments its own logical clock in the vector by one (as in the bullet above, but not twice for the same event) then it pairs the message with a copy of its own vector and finally sends the pair.
- Each time a process receives a message-vector clock pair, it increments its own logical clock in the vector by one and updates each element in its vector by taking the maximum of the value in its own vector clock and the value in the vector in the received pair (for every element). For example, if process receives a message from , it first increments its own logical clock in the vector by one and then updates its entire vector by setting .
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:
- denotes the vector clock of event , and denotes the component of that clock for process .
-
- In English: is less than , if and only if is less than or equal to for all process indices , and at least one of those relationships is strictly smaller (that is, ).
- denotes that event happened before event . It is defined as: if , then
Properties:
- Antisymmetry: if , then ¬
- Transitivity: if and , then ; or, if and , then
Relation with other orders:
- Let be the real time when event occurs. If , then
- Let be the Lamport timestampof event . If , then
Other mechanisms
- In 1999, Torres-Rojas and Ahamad developed Plausible Clocks,[7] a mechanism that takes less space than vector clocks but that, in some cases, will totally order events that are causally concurrent.
- In 2005, Agarwal and Garg created Chain Clocks,[8] a system that tracks dependencies using vectors with size smaller than the number of processes and that adapts automatically to systems with dynamic number of processes.
- In 2008, Almeida et al. introduced Interval Tree Clocks.[9][10][11] This mechanism generalizes Vector Clocks and allows operation in dynamic environments when the identities and number of processes in the computation is not known in advance.
- In 2019, Lum Ramabaja proposed Bloom Clocks, a probabilistic data structure based on Compared to a vector clock, the space used per node is fixed and does not depend on the number of nodes in a system. Comparing two clocks either produces a true negative (the clocks are not comparable), or else a suggestion that one clock precedes the other, with the possibility of a false positive where the two clocks are unrelated. The false positive rate decreases as more storage is allowed.
See also
- Lamport timestamps
- Matrix clocks
- Version vector
References
- ^ "Distributed Systems 3rd edition (2017)". DISTRIBUTED-SYSTEMS.NET. Retrieved 2021-03-21.
- S2CID 215822405.
- ^ S2CID 3065996.
- ^ Kuper, Lindsey (8 April 2023). "Who invented vector clocks?". decomposition ∘ al. The papers are (in chronological order):
- Fischer, Michael J.; Michael, Alan (1982). "Sacrificing serializability to attain high availability of data in an unreliable network". Proceedings of the 1st ACM SIGACT-SIGMOD symposium on Principles of database systems - PODS '82. p. 70. S2CID 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. (May 1983). "Detection of Mutual Inconsistency in Distributed Systems". IEEE Transactions on Software Engineering. SE-9 (3): 240–247. S2CID 2483222.
- Wuu, Gene T.J.; Bernstein, Arthur J. (1984). "Efficient solutions to the replicated log and dictionary problems". Proceedings of the third annual ACM symposium on Principles of distributed computing - PODC '84. pp. 233–242. S2CID 2384672.
- Strom, Rob; Yemini, Shaula (August 1985). "Optimistic recovery in distributed systems". ACM Transactions on Computer Systems. 3 (3): 204–226. S2CID 1941122.
- Schmuck, Frank B. (November 1985). Software clocks and the order of events in a distributed system (unpublished).
- Liskov, Barbara; Ladin, Rivka (1986). "Highly available distributed services and fault-tolerant distributed garbage collection". Proceedings of the fifth annual ACM symposium on Principles of distributed computing - PODC '86. pp. 29–39. S2CID 16148617.
- Raynal, Michel (February 1987). "A distributed algorithm to prevent mutual drift between n logical clocks". Information Processing Letters. 24 (3): 199–202. .
- Fischer, Michael J.; Michael, Alan (1982). "Sacrificing serializability to attain high availability of data in an unreliable network". Proceedings of the 1st ACM SIGACT-SIGMOD symposium on Principles of database systems - PODS '82. p. 70.
- ^ Fidge, Colin J. (February 1988). "Timestamps in message-passing systems that preserve the partial ordering" (PDF). In K. Raymond (ed.). Proceedings of the 11th Australian Computer Science Conference (ACSC'88). Vol. 10. pp. 56–66. Retrieved 2009-02-13.
- ^ Mattern, Friedemann (October 1988). "Virtual Time and Global States of Distributed systems". In Cosnard, M. (ed.). Proc. Workshop on Parallel and Distributed Algorithms. Chateau de Bonas, France: Elsevier. pp. 215–226.
- S2CID 2936350
- S2CID 11779779. Retrieved 21 April 2021.
- ISBN 978-3-540-92220-9
- ISBN 978-3-540-92220-9
- ^ Zhang, Yi (2014), "Background Preliminaries: Interval Tree Clock Results", Background Preliminaries: Interval Tree Clock Results (PDF)
- S2CID 220362525.
- Bibcode:2019arXiv190513064R
- S2CID 233476293.
External links
- Why Logical Clocks are Easy (Compares Causal Histories, Vector Clocks and Version Vectors)
- Explanation of Vector clocks
- Timestamp-based vector clock implementation in Erlang
- Vector clock implementation in Objective-C
- Vector clock implementation in Erlang
- Why Vector Clocks are Hard
- Why Cassandra doesn’t need vector clocks