Course contentsShow
← System Design
Lesson 562 of 1,91915. Consistency ModelsFree lesson

Version Vectors and Conflict Detection

Using version vectors or vector clocks to detect concurrent writes and conflicts in quorum systems.

Version Vectors and Conflict Detection

What you'll learn: How distributed systems use version vectors to detect when two replicas have written conflicting data concurrently.

The Problem with Concurrent Writes

In a quorum system, multiple replicas can receive writes at nearly the same time. How do you know if two writes happened concurrently (a real conflict) versus one happening clearly after the other (can be safely overwritten)?

What is a Version Vector?

A version vector (also called vector clock) is like a scoreboard where each replica tracks how many writes it has seen from every replica in the system.

Analogy: Imagine three friends editing a shared document. Each friend keeps a sticky note saying "Alice made 3 edits, Bob made 2 edits, Carol made 5 edits." When they compare notes, they can tell if someone worked with outdated information.

How Version Vectors Detect Conflicts

Each write increments the originating replica's counter. When comparing two version vectors:

  • One dominates (all counters ≥ the other): The higher one happened after. No conflict.
  • Neither dominates: The writes were concurrent. Conflict detected!

Example:

  • Replica A writes: {A:1, B:0, C:0}
  • Replica B writes: {A:0, B:1, C:0}
  • Neither dominates → concurrent writes → conflict

But if we see {A:2, B:1, C:0} vs {A:1, B:1, C:0}, the first dominates (happened after), so no conflict.

Why This Matters

Without version vectors, quorum systems would blindly overwrite data using timestamps (which can be wrong due to clock drift). Version vectors give you causality-based conflict detection that works despite clock skew.

Key Takeaway: Version vectors track per-replica write counts to reliably detect concurrent writes in quorum systems, enabling proper conflict resolution instead of silent data loss.