Skip to content
WebsiteHosting.com

concept Backend & software

Raft log conflicts and commit indexes

A Raft follower can acknowledge a log entry before it is committed or applied. Follow one request to see why a new leader counts replicas of a current-term entry, not just copies of an older one.

Latest recorded source check · P0129

What it means

A new Raft leader cannot declare an older log entry committed just because it finds that entry on a majority of servers. To advance its commit index by counting replicas, the leader needs a majority for an entry from its current term. Commitment then covers the whole log through that entry, including earlier entries. Applying the committed commands to a state machine is a separate step.

An index is a position in the log. The term recorded there tells you which leadership term the entry came from. After a leader change, two servers can have an entry at the same index but with different terms. Counting occupied positions is not the same as counting matching entries.

Try it

Simulation. Compare two requests to the same starting logs. First use the default First leader index sent of 2. Then change only that value to 3. Watch which preceding entry follower B must match before it can accept anything. Each choice starts from the logs below, not from the result of the previous choice.

Raft log conflicts and commit indexes

Distinguish replicated, acknowledged and committed log entries under leadership changes

Simulation
Modeled outcome: Commit

A current-term index is replicated by a majority; commitment advances through it. Application is separate.

Raft log conflicts and commit indexes: synthetic scenario inputs
Replaces all inputs with the documented starting example and the indicated change. Reset restores the starting example.
Log matching, commit and apply

Leader A

  1. Index 1Term 1
  2. Index 2Term 2
  3. Index 3Term 3

Follower B before

  1. Index 1Term 1
  2. Index 2Term 1
  3. Index 3Term 1

Previous-index gate

  1. Required previous index1
  2. Required term1
  3. B term1
  4. ReplyAccept

Follower B after

  1. Index 1Term 1
  2. Index 2Term 2
  3. Index 3Term 3

C known matching prefix

  1. Index 1Term 1
  2. Index 2Unconfirmed
  3. Index 3Unconfirmed

Copies and replaced suffix

  1. Confirmed copies at index 22
  2. Confirmed copies at index 32
  3. Replaced B terms1, 1
B confirmed by this request3 index
A commit3 index
A applied2 index

The fixed leader has terms 1, 2, 3. C represents a confirmed matching prefix only. An unsuccessful request to B provides no new match proof. The two copy counts are for leader entries, not arbitrary entries with the same index.

Evaluated inputs

Required scenario evidence
provided
First leader index sent
2 index
Follower C known matching prefix
1
Follower B log terms
1,1,1
Leader apply budget
1 entries

Fixed elected leader A term 3, log terms [1,2,3], prior commit/applied=1. B has a stipulated log or unavailable, C has stipulated known matching prefix; one AppendEntries containing suffix through index 3, successful response confirms all entries through 3. No arbitrary election, network, snapshots or membership change.

About this model

The controls set only a local, bounded scenario. The computed branch is not a verdict about a live system. Inputs listed as not evaluated did not participate in this branch after validation.

Reset restores the original inputs. It does not change the open or closed state of help or FAQ answers.

Before the requestIndex 1Index 2Index 3
A, leader in term 3Term 1Term 2Term 3
B, followerTerm 1Term 1Term 1
C, known matching prefixTerm 1UnknownUnknown

A starts with index 1 committed and applied. The request to B contains A's entries from the selected index through index 3. C receives no request in this example; only its stated matching prefix counts.

Start at index 2: The preceding entry is index 1, term 1, on both A and B. B accepts the request. At index 2 it finds the first conflict, removes its two uncommitted term-1 entries, and appends A's terms 2 and 3. B's reply establishes a match index of 3: A now knows B's log agrees with its own through that position. Indexes 2 and 3 each have two confirmed copies, on A and B. Index 3 is from A's current term, so A commits through 3. With a budget of one additional entry, A applies index 2; index 3 is committed but not yet applied on A.

Start at index 3: The request now depends on index 2 already matching. A has term 2 there, but B has term 1. B rejects the request without deleting or appending anything. With C known to match only through index 1, A has just one confirmed copy of its entry at index 3: its own. Its commit and applied indexes both stay at 1. Reset restores the original inputs and the first result.

Why two copies can still be insufficient

Keep the first index sent at 3, but change Follower C known matching prefix from 1 to 2. B still rejects the request. Now A and C match at index 2: two servers out of three, a majority. Yet that entry is from term 2, and only A is known to hold the entry from term 3. The commit index stays at 1, not 2.

The distinction is about what those two copies prove. Section 5.4.2 of the Raft paper shows how an older entry can be present on a majority and still be overwritten under a later leader. That is why the leader tests the term as well as the replica count. In the default example, index 2 becomes committed because index 3 qualifies, not because index 2 independently passes a copy-count test.

A rejection is also different from no reply. If B is offline, its log is unknown, not empty. If C is known to match through index 3, A and C establish a current-term majority without B. By contrast, setting Required scenario evidence to missing gives no replication, commit, or application result at all. The simulation considers one request under an already elected leader; it does not simulate the election, retries, snapshots, membership changes, or a live network.

In the log rows, an unconfirmed entry for C means that the model has no matching-prefix evidence there; it does not mean the entry is absent. A further contrast is to keep the default accepted append and set the apply budget to zero. A still commits through index 3, but its applied index remains at 1. Changing application progress does not undo the majority evidence.

In practice

When reading logs after a leader change, identify the leader's term and the term at the index you care about. Then distinguish the matching prefix confirmed for each follower from the leader's commit index. If the question is whether a command has taken effect on a particular server, look for that server's applied position rather than another copy of the log entry.

The etcd Raft library's usage example makes this distinction concrete: it separates persisting entries delivered in Ready from processing CommittedEntries in the state machine. Finding an entry in storage is not evidence that the state machine has processed it.

Default example, after B repliesThrough indexWhat the marker tells you
B's confirmed match3B has A's prefix through the term-3 entry.
A's commit index3A and B form a majority for that current-term entry.
A's applied index2A has processed index 2; index 3 is still waiting.

Read each marker as an answer to a different question: Who has the entry? Is it committed? Has this server acted on it? If all you have is a follower's acknowledgment, report the confirmed match and leave application unconfirmed.

Frequently asked questions

Editorial questions based on the listed sources and explicitly labeled local examples.

Does acknowledged equal applied?

No. A successful replication acknowledgment establishes a matching prefix under this model. Commit depends on the leader’s quorum and term rules, and application can lag behind commit on a particular server.

Can older entries become committed?

Yes. The leader can directly advance its commit index using a replicated current-term entry; earlier entries in the prefix then become committed indirectly.

Why check previous index and term?

The previous index and term test ties the new entries to an already matching log prefix. A mismatching prefix must be resolved rather than appending blindly.

Can an uncommitted suffix be replaced?

Yes. Raft resolves conflicts using the log-matching rules and can replace conflicting uncommitted suffixes. This is not permission to discard committed entries.

Sources & model boundaries

Primary references used for this explanation. The interactive example is an educational model, not a live check.

  1. Ongaro and Ousterhout: In Search of an Understandable Consensus Algorithm

    5.3,5.4.2. Votes constrained by term/log freshness; AppendEntries checks preceding index/term; conflicting suffix deletion; direct commit rule requires current-term majority, prior entries follow indirectly.

    Checked .

  2. etcd Raft library: Usage

    State machine handling loop. The etcd Raft library example distinguishes persisting Ready entries from processing CommittedEntries in the state machine; log presence alone is not the application effect.

    Checked .

Report an issue. Include the article URL and ID, not passwords or access keys.