Misplaced Pages

Vector clock

Article snapshot taken from Wikipedia with creative commons attribution-sharealike license. Give it a read and then ask your questions in the chat. We can research this topic together.
(Redirected from Vector clocks) Algorithm for partial ordering of events and detecting causality in distributed systems Not to 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 V C i {\displaystyle VC_{i}} as the vector clock maintained by process i {\displaystyle i} , the clock updates proceed as follows:

Example of a system of vector clocks. Events in the blue region are the causes leading to event B4, whereas those in the red region are the effects of event B4.
  • 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 i {\displaystyle i} , it updates V C i [ i ] V C i [ i ] + 1 {\displaystyle VC_{i}\leftarrow VC_{i}+1} .
  • 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 P i {\displaystyle P_{i}} receives a message ( m , V C j ) {\displaystyle (m,VC_{j})} from P j {\displaystyle P_{j}} , it first increments its own logical clock in the vector by one V C i [ i ] V C i [ i ] + 1 {\displaystyle VC_{i}\leftarrow VC_{i}+1} and then updates its entire vector by setting V C i [ k ] max ( V C i [ k ] , V C j [ k ] ) , k {\displaystyle VC_{i}\leftarrow \max(VC_{i},VC_{j}),\forall k} .

History

Lamport originated the idea of logical Lamport clocks in 1978. 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. At least 6 papers contain the concept. The papers canonically cited in reference to vector clocks are Colin Fidge’s and Friedemann Mattern’s 1988 works, as they (independently) established the name "vector clock" and the mathematical properties of vector clocks.

Partial ordering property

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

  • V C ( x ) {\displaystyle VC(x)} denotes the vector clock of event x {\displaystyle x} , and V C ( x ) z {\displaystyle VC(x)_{z}} denotes the component of that clock for process z {\displaystyle z} .
  • V C ( x ) < V C ( y ) z [ V C ( x ) z V C ( y ) z ] z [ V C ( x ) z < V C ( y ) z ] {\displaystyle VC(x)<VC(y)\iff \forall z\land \exists z'}
    • In English: V C ( x ) {\displaystyle VC(x)} is less than V C ( y ) {\displaystyle VC(y)} , if and only if V C ( x ) z {\displaystyle VC(x)_{z}} is less than or equal to V C ( y ) z {\displaystyle VC(y)_{z}} for all process indices z {\displaystyle z} , and at least one of those relationships is strictly smaller (that is, V C ( x ) z < V C ( y ) z {\displaystyle VC(x)_{z'}<VC(y)_{z'}} ).
  • x y {\displaystyle x\to y\;} denotes that event x {\displaystyle x} happened before event y {\displaystyle y} . It is defined as: if x y {\displaystyle x\to y\;} , then V C ( x ) < V C ( y ) {\displaystyle VC(x)<VC(y)}

Properties:

  • Antisymmetry: if V C ( a ) < V C ( b ) {\displaystyle VC(a)<VC(b)} , then ¬ ( V C ( b ) < V C ( a ) ) {\displaystyle (VC(b)<VC(a))}
  • Transitivity: if V C ( a ) < V C ( b ) {\displaystyle VC(a)<VC(b)} and V C ( b ) < V C ( c ) {\displaystyle VC(b)<VC(c)} , then V C ( a ) < V C ( c ) {\displaystyle VC(a)<VC(c)} ; or, if a b {\displaystyle a\to b\;} and b c {\displaystyle b\to c\;} , then a c {\displaystyle a\to c\;}

Relation with other orders:

  • Let R T ( x ) {\displaystyle RT(x)} be the real time when event x {\displaystyle x} occurs. If V C ( a ) < V C ( b ) {\displaystyle VC(a)<VC(b)} , then R T ( a ) < R T ( b ) {\displaystyle RT(a)<RT(b)}
  • Let C ( x ) {\displaystyle C(x)} be the Lamport timestamp of event x {\displaystyle x} . If V C ( a ) < V C ( b ) {\displaystyle VC(a)<VC(b)} , then C ( a ) < C ( b ) {\displaystyle C(a)<C(b)}

Other mechanisms

This list is incomplete; you can help by adding missing items. (June 2023)
  • In 1999, Torres-Rojas and Ahamad developed Plausible Clocks, 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, 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. 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 Bloom filters. 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

References

  1. "Distributed Systems 3rd edition (2017)". DISTRIBUTED-SYSTEMS.NET. Retrieved 2021-03-21.
  2. Lamport, L. (1978). "Time, clocks, and the ordering of events in a distributed system" (PDF). Communications of the ACM . 21 (7): 558–565. doi:10.1145/359545.359563. S2CID 215822405.
  3. ^ Schwarz, Reinhard; Mattern, Friedemann (March 1994). "Detecting causal relationships in distributed computations: In search of the holy grail". Distributed Computing. 7 (3): 149–174. doi:10.1007/BF02277859. S2CID 3065996.
  4. 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. doi:10.1145/588111.588124. ISBN 0897910702. 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. doi:10.1109/TSE.1983.236733. 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. doi:10.1145/800222.806750. ISBN 0897911431. S2CID 2384672.
    • Strom, Rob; Yemini, Shaula (August 1985). "Optimistic recovery in distributed systems". ACM Transactions on Computer Systems. 3 (3): 204–226. doi:10.1145/3959.3962. 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. doi:10.1145/10590.10593. ISBN 0897911989. S2CID 16148617.
    • Raynal, Michel (February 1987). "A distributed algorithm to prevent mutual drift between n logical clocks". Information Processing Letters. 24 (3): 199–202. doi:10.1016/0020-0190(87)90186-4.
  5. 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.
  6. 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.
  7. Francisco Torres-Rojas; Mustaque Ahamad (1999), "Plausible clocks: constant size logical clocks for distributed systems", Distributed Computing, 12 (4): 179–195, doi:10.1007/s004460050065, S2CID 2936350
  8. Agarwal, Anurag; Garg, Vijay K. (17 July 2005). "Efficient dependency tracking for relevant events in shared-memory systems" (PDF). Proceedings of the twenty-fourth annual ACM symposium on Principles of distributed computing. Association for Computing Machinery. pp. 19–28. doi:10.1145/1073814.1073818. ISBN 1-58113-994-2. S2CID 11779779. Retrieved 21 April 2021.
  9. Almeida, Paulo; Baquero, Carlos; Fonte, Victor (2008), "Interval Tree Clocks: A Logical Clock for Dynamic Systems", in Baker, Theodore P.; Bui, Alain; Tixeuil, Sébastien (eds.), Principles of Distributed Systems (PDF), Lecture Notes in Computer Science, vol. 5401, Springer-Verlag, Lecture Notes in Computer Science, pp. 259–274, Bibcode:2008LNCS.5401.....B, doi:10.1007/978-3-540-92221-6, ISBN 978-3-540-92220-9
  10. Almeida, Paulo; Baquero, Carlos; Fonte, Victor (2008), "Interval Tree Clocks: A Logical Clock for Dynamic Systems", Interval Tree Clocks: A Logical Clock for Dynamic Systems, Lecture Notes in Computer Science, vol. 5401, p. 259, doi:10.1007/978-3-540-92221-6_18, hdl:1822/37748, ISBN 978-3-540-92220-9
  11. Zhang, Yi (2014), "Background Preliminaries: Interval Tree Clock Results", Background Preliminaries: Interval Tree Clock Results (PDF)
  12. Pozzetti, Tommaso; Kshemkalyani, Ajay D. (1 April 2021). "Resettable Encoded Vector Clock for Causality Analysis With an Application to Dynamic Race Detection". IEEE Transactions on Parallel and Distributed Systems. 32 (4): 772–785. doi:10.1109/TPDS.2020.3032293. S2CID 220362525.
  13. Lum Ramabaja (2019), The Bloom Clock, arXiv:1905.13064, Bibcode:2019arXiv190513064R
  14. Kulkarni, Sandeep S; Appleton, Gabe; Nguyen, Duong (4 January 2022). "Achieving Causality with Physical Clocks". Proceedings of the 23rd International Conference on Distributed Computing and Networking. pp. 97–106. arXiv:2104.15099. doi:10.1145/3491003.3491009. ISBN 9781450395601. S2CID 233476293.

External links

Category: