Highlights

Contents

Part III
03

Replication, ISR, high watermark

We decide which appended records readers may trust. Copies that lag have different failure value. We will follow ISR, acknowledgements, high watermarks, and leader change.

CHAPTER ATLAS / FOLLOW THE READING PATHCHAPTER ATLAS / FOLLOW THE READING PATH1Topics, partitions andrecords2Producers and brokers3Replication, ISR, highwatermark4Consumers, offsets andsemantics5Consumer groups andrebalancing6Idempotence andtransactions7Retention, compaction andreplay8Operating Kafka: KRaftand lag9Case study: one scoreevent

#Section 9Leader, followers, and ISR

The leader has appended through 103, but a follower has only reached 102. A follower replica copies the leader’s partition history. The in-sync replica set, or ISR, tracks replicas meeting Kafka’s documented synchronization criteria.

Followers fetch from the leader and report their progress. The leader and one follower have next position 104 while another ISR member has 103. Their minimum next position is 103 in this simple trace, which limits replicated visibility until the slower replica catches up or membership changes under the protocol. Replica count says how many configured copies exist; ISR says which replicas currently satisfy the relevant synchronization state. Neither is simply a promise that all configured nodes hold every latest record at all times.

The slow follower’s local receipt and the leader’s observation of its progress are separate events. The leader must learn enough replication state under the protocol before advancing the shared visibility boundary. If a replica leaves the current in-sync set, reassess the acknowledgement condition and minimum requirement rather than keep treating the original membership as current. A configured copy that is offline cannot serve as a witness to a new append. Monitor per-partition progress and membership because an aggregate replica count cannot locate the tail that limits this partition.

REPLICATION PROGRESS CAN LEAVE A LOCAL TAIL NOT YET VISIBLEREPLICATION PROGRESS CAN LEAVE A LOCAL TAIL NOT YET VISIBLEleader100101102103104follower A100101102103104follower B100101102absent103watermark 103records 100 through 102 are below the exclusive boundary
Figure 9.9Illustrative replica progress. Leader and follower A have next position 104, while follower B has 103. The exclusive watermark at 103 keeps the local tail beyond it out of the visible prefix.

ISR membership is protocol state, not a static count chosen once at topic creation. Explain writes after membership shrinks.

#Section 10Acknowledgements and minimum ISR

The producer uses a strong replicated acknowledgement policy and the topic requires a minimum of two ISR members in the illustrative three-copy setup. Producer acknowledgements define when a produce operation reports success; min.insync.replicas constrains eligible writes under the relevant acks=all policy.

With enough eligible replicas, the leader waits for the configured replication acknowledgement behavior. If the ISR shrinks below the required minimum, the write fails rather than silently meeting a weaker replica count. acks=1 instead confirms the leader path without the same all-ISR condition; acks=0 does not wait for a broker acknowledgement. These are distinct trade-offs, not universal durability grades independent of other settings. See Kafka 4.1 producer configuration and topic configuration.

In the declared replication fixture, the leader and follower A have next position 104 while follower B is still at 103. A policy requiring acknowledgements from the current in-sync set must account for that lag rather than equating the leader append with completion. The configured minimum ISR is a condition for accepting the write under the relevant acknowledgement mode; it is not simply the number of copies a client asks to return. If too few eligible replicas remain, refusing the write preserves the chosen contract at the cost of availability. Restoring a response quickly by weakening that policy changes the durability promise.

acks=all WITH min.insync=2: WITH ONE IN-SYNC COPY, THE WRITE IS REFUSEDacks=all WITH min.insync=2: WITH ONE IN-SYNC COPY, THE WRITE IS REFUSEDacks=all, min ISR 2leaderfollowerfollowerISR = 1 < 2NotEnoughReplicas: rejectacks=1leaderfollowerfolloweraccepted on one copythe weaker setting answers faster and can lose the write with the leader
Figure 9.10The rows compare three configured copies with current ISR and minimum-ISR policy; orange marks the strong policy that rejects a write below two live in-sync copies.

Saying acks all means every configured replica is wrong when some configured replicas are outside the ISR. Use the product’s documented protocol and membership semantics.

#Section 11The high watermark

The slow follower reaches next position 104. The high watermark is the replication-defined boundary of records safe for the ordinary consumer visibility rule. This unit uses an exclusive-next-offset convention for its examples.

Before catch-up, the simple three-member progress trace has positions 104, 104, and 103, with boundary 103. After the final follower reaches 104, the boundary can advance to 104 once the protocol observes and confirms the relevant progress. All four illustrative records are then below it. The real protocol has report and observation steps, so a follower’s local append is not a magical instantaneous global update. Transactional readers can have a lower last stable offset even when replication is current.

A consumer waiting at 103 can fetch the final fixture record only after the exclusive replicated boundary permits it. Once the relevant progress is observed and the boundary reaches 104, that record lies below the boundary. This step does not advance the consumer group’s checkpoint, which still depends on its own safely completed effects. A committed transactional reader can remain blocked by a lower stable boundary even after replication catches up. Inspect the reason for each wait rather than equate follower catch-up with immediate application progress.

THE HIGH WATERMARK RISES FROM 103 TO 104 ONCE EVERY IN-SYNC REPLICA HAS 103THE HIGH WATERMARK RISES FROM 103 TO 104 ONCE EVERY IN-SYNC REPLICA HAS 103leader100101102103follower 1100101102103follower 2100101102103HW 103HW 104: 103 visiblethe consumer group's checkpoint does not move with it
Figure 9.11The trace raises the high watermark from 103 to 104 as all replicas catch up; orange marks the post-catch-up visible boundary.

Adding leader and follower offsets together measures nothing useful. Compare progress in the same partition and convention.

#Section 12Leader failover and divergent tails

The leader fails after appending a record that was not safely replicated. A replacement must use a history compatible with the successful-write contract. A leader epoch identifies a generation of partition leadership so stale leaders and divergent histories can be detected.

The metadata authority selects an eligible leader under the configured protocol and updates clients. Replicas compare history and reconcile their tails using the epoch and replication rules. Promoting a stale replica under an unsafe availability policy can lose previously visible or acknowledged data; avoiding that promotion can keep the partition unavailable. Kafka 4.1 also documents eligible-leader mechanisms beyond the simple classroom ISR trace. Name the chosen settings and eligibility model rather than assuming every version has exactly one election path.

Let the former leader return after replacement. Its local segment may contain a tail that the new authoritative history does not retain, and being alive again does not authorize it to restore that tail as accepted state. It must follow the accepted leadership epoch and history-reconciliation protocol. Clients with stale metadata refresh their route instead of independently choosing the recovered node. If no eligible history meets the configured survival promise, the availability policy must describe whether the partition waits. Recovered files, current leadership, and promised write survival are different checks.

THE OLD LEADER'S UNREPLICATED TAIL IS DISCARDED; THE NEW EPOCH IS THE SOURCETHE OLD LEADER'S UNREPLICATED TAIL IS DISCARDED; THE NEW EPOCH IS THE SOURCEold leader100101102103104follower → leader100101102epoch 6old leader returns100101102truncate to 103, fetchbeing alive again does not make 103 and 104 accepted
Figure 9.12The failover rows discard an unreplicated tail, select an eligible history, and reconcile the new leader; orange marks the safe source after epoch change.

An old process remaining alive does not make it current leader. Clients and brokers must reject obsolete authority under the protocol.