Vector clock

From Wikipedia, the free encyclopedia
Jump to navigation Jump to search

Template:Short description Script error: No such module "Distinguish". 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]

File:Vector Clock.svg
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, it updates VCi[i]VCi[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 Pi receives a message (m,VCj) from Pj, it first increments its own logical clock in the vector by one VCi[i]VCi[i]+1 and then updates its entire vector by setting VCi[k]max(VCi[k],VCj[k]),k.

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)z[VC(x)zVC(y)z]z[VC(x)z<VC(y)z]
    • In English: 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).
  • xy denotes that event x happened before event y. It is defined as: if xy, then VC(x)<VC(y)

Properties:

  • Antisymmetry: if VC(a)<VC(b), then ¬(VC(b)<VC(a))
  • Transitivity: if VC(a)<VC(b) and VC(b)<VC(c), then VC(a)<VC(c); or, if ab and bc, then ac

Relation with other orders:

  • Let RT(x) be the real time when event x occurs. If VC(a)<VC(b), then RT(a)<RT(b)
  • Let C(x) be the Lamport timestamp of event x. If VC(a)<VC(b), then C(a)<C(b)

Limitations under Byzantine Failures

Vector clocks can reliably detect causality in distributed systems subject to crash failures. However, when processes behave arbitrarily or maliciously—as in the Byzantine failure model—causality detection becomes fundamentally impossible [7] , rendering vector clocks ineffective in such environments. This impossibility result holds for all variants of vector clocks, as it stems from core limitations inherent to the problem of causality detection under Byzantine faults.

Other mechanisms

Script error: No such module "Unsubst".

  • In 1999, Torres-Rojas and Ahamad developed Plausible Clocks,[8] 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,[9] 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.[10][11][12] 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.[13][14][15] 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

Template:Reflist

External links

  1. Script error: No such module "citation/CS1".
  2. Script error: No such module "Citation/CS1".
  3. a b Script error: No such module "Citation/CS1".
  4. Script error: No such module "citation/CS1". The papers are (in chronological order):
    • Script error: No such module "citation/CS1".
    • Script error: No such module "Citation/CS1".
    • Script error: No such module "citation/CS1".
    • Script error: No such module "Citation/CS1".
    • Script error: No such module "citation/CS1".
    • Script error: No such module "citation/CS1".
    • Script error: No such module "Citation/CS1".
  5. Script error: No such module "citation/CS1".
  6. Script error: No such module "citation/CS1".
  7. Script error: No such module "citation/CS1".
  8. Script error: No such module "citation/CS1".
  9. Script error: No such module "citation/CS1".
  10. Script error: No such module "citation/CS1".
  11. Script error: No such module "citation/CS1".
  12. Script error: No such module "citation/CS1".
  13. Script error: No such module "Citation/CS1".
  14. Script error: No such module "citation/CS1".
  15. Script error: No such module "citation/CS1".