Scrivio Interview library
ConceptFoundations6 min read · updated 13 November 2026

A broker is restarted with a controlled shutdown while producers and consumers are active.

Describe what the clients experience during the leader change, and explain why a producer using acks=1 can lose records in an unplanned leader failure while acks=all does not.

During a controlled shutdown the controller moves leadership of the broker's partitions to other ISR members, so clients get NOT_LEADER_OR_FOLLOWER errors or a disconnect, refresh metadata and switch to the new leaders, usually within a second or two; producers retry inside delivery.timeout.ms and idempotence prevents duplicates, while consumers continue from their position on the new leader. In an unplanned failure, acks=1 can lose records because the leader acknowledged after only its local write; a follower without the record becomes leader and the old leader truncates it later. acks=all waits for every in-sync replica, so any eligible new leader already has the record.

Why this question is asked

Rolling restarts happen every week in most Kafka deployments, for upgrades, config changes and host patching, so knowing what clients see during a leader change is everyday knowledge. And acks is the most important producer setting for durability, often left at a value nobody chose on purpose. Interviewers pair these two topics to check that we understand both the smooth case and the failure case. In this answer, we will recap leaders and acks, follow a controlled shutdown from the clients' side, then follow an unplanned failure with acks=1 to see exactly how a record is lost, and see why acks=all prevents it and why consumers never notice.

1A Quick Recap of Leaders and acks

Each partition has one leader replica that receives all writes, and followers that fetch from it. The in-sync replicas, the ISR, are the followers that are caught up. The high watermark is the offset up to which every ISR member has the data, and consumers can read only below it.

The producer's acks setting says when a write counts as successful. acks=0 means do not wait at all. acks=1 means the leader has written the record to its own log. acks=all means every current ISR member has it. Since Kafka 3.0 the default is acks=all, together with idempotence, but many older applications still set acks=1 explicitly for lower latency.

2What Clients See During a Controlled Shutdown

When we stop a broker normally, it first asks the controller to move its leadership away. The controller picks a new leader for each of its partitions from the other ISR members and records the change, and other brokers start acting as leaders. The stopping broker then closes its connections and exits.

A producer sending to one of those partitions gets a NOT_LEADER_OR_FOLLOWER error from the old leader, or sees the connection close. Both are retriable. It refreshes its metadata, learns the new leader, and resends the pending batches there. This usually takes a second or two, well inside delivery.timeout.ms (2 minutes by default), so the application sees a short latency bump and no errors. With idempotence on, if a batch was written just before the switch and the producer resends it, the broker recognises the producer id and sequence number and does not write it twice.

Consumers behave the same way: their fetch fails, they refresh metadata and continue fetching from the new leader at the same position. Their position is an offset, and offsets mean the same thing on every replica, so nothing is skipped or reread.

Step throughA producer during a controlled shutdown
ProducerOld leaderControllerNew leader
I want to shut down
elect new leaders from the ISR
you now lead orders-3
produce batch
NOT_LEADER_OR_FOLLOWER
refresh metadata, resend batch
acknowledged (duplicate dropped if any)

7 messages in order. Play them, or step through them one at a time.

The leader moves before the broker stops, so the client only needs one retry.

3How acks=1 Loses a Record in an Unplanned Failure

Now take a crash instead of a controlled shutdown, and a producer using acks=1. The leader appends the record at offset 900 and immediately acknowledges it, because acks=1 only needs its local write. The followers have not fetched offset 900 yet; they are a few milliseconds behind, which is normal.

The leader's machine fails at this moment. The controller elects a follower from the ISR as the new leader. That follower's log ends at 899, which is allowed: it was in the ISR because it was keeping up, just not instantly. New writes go to the new leader, and the next record gets offset 900. When the old leader comes back, it truncates its log to match the new leader, so its own record 900 is discarded. The record the producer was told was written no longer exists anywhere.

Java
props.put("acks", "1");
producer.send(new ProducerRecord<>("orders", "o-17", payload)).get();
// RecordMetadata: orders-3@900 (acknowledged by the leader alone)
// leader crashes before followers fetch offset 900
// new leader's log ends at 899; next record written becomes offset 900
// old leader returns and truncates its offset 900: "o-17" is gone

Notice that nothing went wrong in Kafka's rules. acks=1 promised only that the leader had the record, and the leader did, until it failed.

4Why acks=all Does Not Lose It

With acks=all, the leader does not acknowledge offset 900 until every member of the ISR has fetched it. So at the moment the producer receives the acknowledgement, every replica that is eligible to become leader already has the record. If the leader crashes after that, whichever ISR member wins the election has offset 900, and the record survives.

If the leader crashes before the acknowledgement, the producer did not get a success; it retries, and with idempotence the retry is written exactly once on the new leader. The only remaining gap is when the ISR has shrunk to the leader alone, which is why acks=all is paired with min.insync.replicas=2: the leader then refuses the write instead of acknowledging it alone.

acks=1 versus acks=all in a leader crash
acks=1acks=all
Acknowledged whenleader wrote locallyevery ISR member has it
New leader has the recordnot necessarilyalways (clean election)
Old leader on returntruncates the recordnothing to truncate
Producer outcometold success, record lostsuccess, record kept
Latencylowerwaits for followers

5Why Consumers Never See the Lost Record

The lost record was never visible to consumers. Consumers read only below the high watermark, and the high watermark had not passed offset 900, because the followers did not have it. So no consumer read it, and no consumer can be confused by it disappearing.

That makes the loss quiet. The only party that knows about the record is the producer that was told the write succeeded. Downstream systems simply never receive the order, with no error anywhere, which is why acks=1 losses are found much later, through reconciliation or a customer complaint, rather than through monitoring.

6Follow-up questions

Is acks=1 ever the right choice?

For data where an occasional loss during a leader crash is acceptable, such as metrics or debug logs, acks=1 gives slightly lower latency. For anything the business depends on, acks=all with min.insync.replicas=2 is the right default, and it is the client default since Kafka 3.0.

Can a controlled shutdown also lose acks=1 records?

Much less likely, because leadership moves to an ISR member while the old leader is still running and followers have had time to fetch. But it is not a guarantee: acks=1 still acknowledged before replication, so a record written in the last instant before the switch can be missing on the new leader.

How long should delivery.timeout.ms be?

Long enough to cover a leader change and some margin, including the worst case of a crash detected only after the broker session timeout. The default of two minutes works for most applications; very latency-sensitive ones may lower it and handle the failures themselves.

7Conclusion

In this answer, we saw that during a controlled shutdown the controller moves leadership to other ISR members first, so producers and consumers see a retriable error, refresh metadata and continue on the new leader within a second or two, with idempotence preventing duplicates. In an unplanned failure, acks=1 can lose a record because only the leader had it when it was acknowledged, and the old leader truncates it on return, while acks=all guarantees every eligible leader already has the record. Consumers never see such a lost record, because it was above the high watermark.

What to say in the interviewAbout 80 seconds aloud

Open with

In a controlled shutdown the broker asks the controller to move its leadership first, so the controller elects new leaders from the other in-sync replicas before the broker stops.

Then, if they want more

Producers get a NOT_LEADER_OR_FOLLOWER error or a disconnect, refresh metadata and resend to the new leader, usually within a second or two, well inside delivery.timeout.ms, and idempotence makes sure a resent batch is not written twice. Consumers also just refresh metadata and keep fetching from the same offset on the new leader. The acks question is about an unplanned crash.

With acks=1 the leader acknowledges as soon as it has written the record locally. If it crashes before the followers fetch that record, the controller elects a follower that does not have it, new records reuse that offset, and when the old leader comes back it truncates its copy. So the producer was told success, but the record is gone.

With acks=all the leader only acknowledges once every in-sync replica has the record, so whichever one is elected already has it, and with min.insync.replicas of 2 that set is never just the leader.

Interestingly, consumers never see the lost acks=1 record, because it was above the high watermark, so the loss is only visible to the producer, which makes it a silent loss.

About this answer

Last updated
13 November 2026
Versions it names
Kafka 3.0
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Official documentation
Apache Kafka documentation
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "Describe what the clients experience during the leader change, and explain why a...": https://scrivio-interview-library.netlify.app/spring-boot/kafka-internals/427600636e/