A topic in the Open Knowledge Graph — a free, open map of 15,290 topics and the order to learn them in.

Vector Clocks and Capturing Causality

Research Depth 95 in the knowledge graph I know this Set as goal
30topics build on this
358prerequisites beneath it
See this on the map →
Logical Clocks and Event OrderingHappened-Before Relation and Causal OrderingHybrid Logical Clocks
vector-clocks causality ordering

Core Idea

Vector clocks extend logical clocks with a vector of integers (one per process). Each process increments its own entry on local events and sets each entry to the maximum of its value and the sender's on message receipt. Vector clocks precisely capture causality: event A happened-before B iff A's vector is less than B's element-wise, and concurrent events have incomparable vectors.

How It's Best Learned

Implement vector clock logic and trace scenarios with concurrent writes and message chains.

Common Misconceptions

Vector clocks require clock synchronization; they can totally order all events; they are necessary for all distributed algorithms.

Explainer

From your study of logical clocks (Lamport clocks), you know that distributed systems can assign timestamps to events without relying on synchronized physical clocks. Lamport clocks give you a useful property: if event A happened before event B, then A's timestamp is less than B's. But the converse is not true — if A's timestamp is less than B's, you cannot conclude that A actually caused B. They might be completely independent events that happened to get ordered by the counter. Vector clocks solve this limitation by making causality detection precise in both directions.

A vector clock is an array of integers, one entry per process in the system. If there are three processes (P1, P2, P3), every event carries a vector like [2, 0, 1]. Each process maintains its own vector and follows two rules. First, before recording a local event, a process increments its own entry in the vector. Second, when a process receives a message, it takes the element-wise maximum of its own vector and the vector attached to the message, then increments its own entry. These two rules are all it takes to capture the full causal history of every event.

The comparison rule is what makes vector clocks powerful. Event A happened before event B if and only if every entry in A's vector is less than or equal to the corresponding entry in B's vector, and at least one entry is strictly less. If neither A ≤ B nor B ≤ A — that is, A has some entries larger than B's and B has some entries larger than A's — then A and B are concurrent. They occurred independently, with no causal chain connecting them. This is information that Lamport clocks simply cannot provide. For example, if A = [2, 3, 1] and B = [3, 1, 2], then A and B are concurrent: A knows more about P2's history, B knows more about P1 and P3. Neither could have influenced the other.

This concurrency detection is essential for conflict resolution in distributed databases. Systems like Amazon's Dynamo use vector clocks (or their compressed variants, version vectors) to detect when two replicas have diverged. If two updates to the same key have comparable vector clocks, the system can automatically keep the later one. If the vectors are incomparable, the system knows a genuine conflict has occurred and can flag it for resolution — either by the application or through a merge function like last-writer-wins. Without vector clocks, the system would have no principled way to distinguish "one update supersedes the other" from "two updates happened independently and both matter."

Practice Questions 5 questions

Prerequisite Chain

Understanding ZeroThe Number ZeroCounting to FiveCounting to 10Counting to 20Counting a Set of Objects Up to 20Cardinality: The Last Number CountedMatching Numerals to QuantitiesSubitizing Small QuantitiesAddition Within 10Number Bonds to 10Addition Within 20Doubles and Near DoublesDoubles Facts Within 10Near Doubles Facts Within 20Mental Math Strategies for AdditionMental Math: Adding and Subtracting TensAddition Within 100Repeated Addition as MultiplicationMultiplication as Equal GroupsMultiplication: ArraysBasic Multiplication Facts (0s, 1s, 2s, 5s, 10s)Multiplication Facts Within 100Division as Equal SharingDivision as Grouping (Measurement Division)Division: Grouping (Repeated Subtraction) ModelDivision: Fair Sharing ModelDivision as Equal SharingDivision as GroupingBasic Division FactsDivision Facts Within 100Multiplication and Division Fact FamiliesRelationship Between Multiplication and DivisionDivision Facts as Inverse of MultiplicationRemainders and Quotients in DivisionDivision Word ProblemsMulti-Step Word ProblemsSolving Multi-Step Word ProblemsMultiplication Word ProblemsDivision Word ProblemsIntroduction to Long DivisionFactors and MultiplesPrime and Composite NumbersEquivalent FractionsRelating Fractions and DecimalsDecimal Place ValueIntegers and the Number LineComparing and Ordering IntegersAbsolute ValueAdding IntegersSubtracting IntegersMultiplying IntegersIntroduction to ExponentsOrder of OperationsInteger Order of OperationsVariable ExpressionsThe Distributive PropertyVariables and Expressions ReviewIntroduction to PolynomialsAdding and Subtracting PolynomialsMultiplying PolynomialsFactorialPermutationsCombinationsCounting Principles: Addition and Multiplication RulesIntroduction to Graph TheoryPropositional Logic FoundationsLogical EquivalencesBoolean AlgebraBoolean Type and Truth ValuesComparison Operators and Boolean TestsLogical Operators and Boolean AlgebraBoolean Algebra and Fundamental LawsLogic Gates FundamentalsImplementing Boolean Functions with GatesKarnaugh Map SimplificationCombinational Circuit DesignFlip-Flops and LatchesBinary Counters: Design and AnalysisBinary ArithmeticFixed-Point Number RepresentationTwo's Complement RepresentationOverflow and Underflow DetectionBinary Adders: Half-Adders and Full-AddersFull Adder and Carry PropagationCarry Lookahead Adder DesignHalf Adder Circuit DesignMultiplication Circuit DesignSequential Circuit DesignRegisters and Register FilesInstruction Set Architecture (ISA)Kernel Architecture and OS StructureSystem Calls and User/Kernel ModeProcesses and the Process Control BlockLogical Clocks and Event OrderingVector Clocks and Capturing Causality

Longest path: 96 steps · 358 total prerequisite topics

Prerequisites (1)

Leads To (2)