Course contentsShow
← System Design
Lesson 625 of 1,91917. Consensus AlgorithmsFree lesson

Log Matching Property

Raft's guarantee that if two logs contain an entry with the same index and term, they are identical up to that point.

Log Matching Property

What you'll learn: How Raft guarantees that matching log entries imply identical history between servers.


The Log Matching Property is a crucial safety guarantee in Raft that ensures consistency across replicated logs. It states: if two logs contain an entry with the same index and term, then they are identical in all entries up to that index.

Why This Matters

Without this property, replicas could have divergent histories, making it impossible to maintain a consistent state machine. The Log Matching Property gives you a simple test: if two servers agree on a single log entry's position (index) and when it was created (term), you know their entire history up to that point is identical.

How Raft Enforces This

Raft maintains this property through two mechanisms:

  1. Leaders never overwrite or delete their own entries — once written at an index in a given term, that entry is permanent for that leader
  2. The AppendEntries RPC includes a consistency check — before accepting new entries, followers verify that their log matches the leader's at the previous index

When a leader sends AppendEntries, it includes the term and index of the entry immediately preceding the new ones. The follower only accepts new entries if its log matches at that position. If not, the follower rejects the request, and the leader tries again with an earlier entry.

An Analogy

Think of building a tower where each block is numbered and stamped with a builder's ID. The Log Matching Property says: if two towers have the same block number with the same builder's stamp, every block below must also be identical. This guarantee lets you verify entire histories by checking just one matching point.

Key Takeaway: The Log Matching Property guarantees that if two logs have entries with matching index and term, their complete histories up to that point are identical, enabling safe replication in Raft.