Commit Semantics
Five topics entangled in ways that matter in production: commit semantics, consumer rebalancing, exactly-once semantics, partition throughput/latency, and zero-copy I/O.
In short. "Committed" means: the message has been written to the local log of every in-sync replica (ISR) and the leader has advanced the high-watermark (HW) past that offset. The HW is the pointer that says "every offset below me is safe to expose to consumers."
The Full Path for a Single Produce (acks=all)
Leader appends record to its local log segment (LEO advances) Leader waits for every ISR follower to fetch that record and acknowledge (each advances its own LEO) Once ALL ISR followers have fetched up to that offset, leader advances HW Leader sends ack back to producer Consumers can now read that offset
Step 1 in plain words — "local log segment" and LEO. Think of each partition as a notebook . You only ever write on the next empty line at the end — you never erase or change old lines. Each line has a number (line 0, line 1, line 2…) — that number is the offset .
Segment: one notebook would get far too thick, so Kafka uses a stack of smaller notebooks. When one fills up, it starts a new one. Each small notebook is a segment — just a file on disk. Kafka only writes in the newest one; the old ones just sit there until they're old enough to throw away.
Local: every broker keeps its own copy of the notebooks on its own disk. "Local" just means "this broker's own copy."
LEO (Log End Offset): a bookmark pointing at the next empty line. If lines 0–499 are written, the LEO is 500.
So step 1 means: the leader writes the new message on the next empty line of its own current notebook, and moves its bookmark down one line (500 → 501). At that moment only the leader has it — the followers haven't copied that line into their notebooks yet. That's why the step says "local": the message isn't safe or "committed" until the followers copy it too (steps 2–3).
"Fetch" in step 2 is long-polling, not a sleep-then-check loop.
Step 2 says the follower "fetches" the record, which sounds like periodic polling with a built-in delay — it isn't. Each follower keeps one fetch request outstanding to the leader at all times. If there's no new data yet, the leader doesn't reject or delay-reply on a timer — it parks the request in purgatory (a DelayedFetch operation) and holds it open. The instant the leader appends new data to its local log, it checks purgatory and immediately completes any pending fetch that can now be satisfied — an event-driven wakeup, not a timer firing. The follower gets the response right away, appends the data, and immediately re-issues its next fetch request, whose offset implicitly acks "I now have up to offset X." The leader sees that offset and advances the HW once every ISR member has reported it. So the added latency is really just two network round trips (data out, ack offset back), not a polling interval. replica.fetch.wait.max.ms (default 500ms) only matters when there's no data flowing — it's a cap on how long an idle fetch request sits in purgatory before the follower is forced to re-poll, not the latency floor for active replication. This is the same long-poll pattern Kafka consumers use via fetch.min.bytes / fetch.max.wait.ms — identical mechanism, just leader↔follower instead of broker↔consumer.
In plain terms: replication happens before the ack, not after.
Each partition has one leader warehouse (broker) and one or more follower warehouses that keep a copy. The producer ships the package to the leader, and the leader writes it to its own disk first — but it does not reply "done" yet. The followers are constantly pulling new data from the leader in the background; only once every in-sync follower has copied that record does the leader mark it safe (the high-watermark) and finally tell the producer "done." So it's not that Kafka replicates after acking — replication is a precondition for the ack. If the leader crashes right after replying "done," you're safe, because "done" was never sent until the copies already existed. This only holds with acks=all — with acks=1 the leader replies immediately after writing locally, before any follower has copied it, which is how Case C below (message acked but then lost) happens.
The Three-Config Interaction
Config Role
replication.factor=3How many copies exist total
acks=allProducer waits for all ISR members
min.insync.replicas=2Minimum ISR size before writes are rejected
With rf=3, min.isr=2, acks=all: a write succeeds if at least 2 brokers (leader + 1 follower) are in ISR and both acknowledge.
Common Misconception. min.insync.replicas does not mean N replicas must acknowledge — it only gates whether the write is accepted at all. acks=all controls who must acknowledge. Both must be set correctly. Either alone is insufficient.
What Happens When the Leader Crashes After Acking, Before Followers Replicate?
Case What happens
A — Follower already replicated (HW advanced) Message is committed. The new leader (elected from ISR) has it. No loss.
B — Follower had not replicated (HW not advanced) With acks=all, this cannot happen — the leader would not have sent the ack until followers acknowledged. The producer's ack means HW already advanced.
C — acks=1 (leader only) Leader acks after writing locally, crashes before followers fetch. New leader elected from ISR — followers are behind. The message is lost. The producer thinks it succeeded.
The fourth case the table doesn't name: leader crashes before acking at all.
The table above is scoped to "crashes after acking" — but there's a case underneath it worth separating out: the leader appends the record locally (LEO advances) and then dies before it ever sends an ack, because no follower fetched it in time. This isn't Case B (that's about a crash after the ack was already sent) — it's a write that was never acknowledged to the producer in the first place. The producer is left hanging (timeout, then retry — safe under enable.idempotence=true). Meanwhile the controller elects a new leader from the ISR, which never had this record, so cluster-wide it's as if the write never happened. When the old leader restarts and rejoins as a follower, it must truncate that dangling record off its own disk to match the new leader's HW — this is exactly the offset-4 scenario in the diagram below. Nothing is "lost" in the durability sense, because nothing was ever promised: the record physically touched a disk, but the contract ("committed" = HW advanced) was never satisfied, so discarding it on recovery doesn't break any guarantee.
A fifth case, and it's the opposite failure mode: HW advances but the ack itself is lost.
All of A/B/C above assume the ack is the thing that does or doesn't get sent. But there's a distinct case: HW does advance — the record is fully committed, durable on every ISR member, visible to consumers — and only the response packet carrying that ack back to the producer gets lost (network blip, producer-side timeout) while the leader stays healthy. The commit itself is final and can't be undone by this; the only open question is what the producer does when it never hears back. It can't distinguish "write failed" from "write succeeded, ack lost," so it retries as if the write hadn't happened. With enable.idempotence=true (see Exactly-once scope and limits, Layer 1 ), this is harmless: the leader still has the record's (PID, partition) → seq in its in-memory register (no crash, no replay needed), recognizes the retry as a duplicate, and returns success without re-appending — the producer just gets a late ack. Without idempotence, the leader has no memory of the earlier write and appends the retry as a new offset — a real duplicate in the log. So unlike Cases A–C, which are about whether a message is lost , this case is about whether a message gets duplicated — the failure mode idempotent producers exist to close.
Truncation on Leader Election
When a new leader is elected, the new leader's log becomes the official one . The leader never truncates its own log. Each follower, and the old leader when it comes back, asks the new leader where its log stops matching. It deletes everything from that point and copies the rest from the new leader. Kafka finds that point using leader epochs , a record of which leader wrote each part of the log.
In the example below, the two logs stop matching at offset 3, which is also the old HW. So "truncate to the HW" and "truncate to where the logs stop matching" give the same answer here. They don't always give the same answer.
"Truncate to the HW" is how Kafka worked before 0.11.
A follower's copy of the HW can be out of date: it lags the leader by one fetch round, and the copy on disk is saved only every 5 seconds. Truncating to that stale number sometimes deleted messages the producer had already been told were saved. KIP-101 (0.11) and KIP-279 (2.0) replaced it with leader-epoch truncation. ◆ Side read: The High Watermark, Step by Step → covers how the HW is computed, where it is stored, and what happens after a crash.
A returning leader discards only what sat above the high watermark
unclean.leader.election.enable=true silently breaks durability.
If all ISR members are down and an out-of-sync replica becomes leader, that replica may be missing messages already acked to producers. Those messages are permanently gone . Defaults to false since Kafka 0.11 — never enable for financial data.
The guarantee: a message acked with acks=all (at rf=3, min.isr=2) survives any single broker failure, and a complete cluster restart. It will not survive if more than rf − min.isr brokers fail simultaneously.