Quick revision
The short answer
With the only ISR member dead and unclean leader election disabled, no replica is eligible to lead, so the partition goes offline: OfflinePartitionsCount rises above zero, producers to it fail and consumers of it stall. We can wait for the failed broker or restore its data, losing nothing but staying unavailable, or run an unclean election that makes the stale replica leader, restoring service but losing the 30,000 records only the dead replica had. If the old replica returns later it truncates to the new leader and new records reuse the lost offsets, so downstream consumers can hold state that no longer matches the log; the choice belongs to the topic's owner, ideally agreed beforehand.
What to remember
In this answer, we saw that when the only ISR member dies with unclean election disabled, the partition goes offline, producers fail and consumers stall. Waiting or restoring the dead replica loses nothing but keeps the partition unavailable, while an unclean election restores service immediately and loses the 30,000 records only that replica held. A returning old replica then truncates to the new leader, new records reuse the lost offsets, and downstream systems may hold data the log no longer has, so the decision belongs to the topic owner, ideally agreed in advance, followed by reconciliation if unclean election is used.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
With the only ISR member dead and unclean leader election disabled, no replica is eligible to lead, so the partition goes offline: OfflinePartitionsCount rises above zero, producers to it fail and consumers of it stall. We can wait for the failed broker or restore its data, losing nothing but staying unavailable, or run an unclean election that makes the stale replica leader, restoring service but losing the 30,000 records only the dead replica had. If the old replica returns later it truncates to the new leader and new records reuse the lost offsets, so downstream consumers can hold state that no longer matches the log; the choice belongs to the topic's owner, ideally agreed beforehand.
Why this question is asked
This is a real dilemma that on-call engineers meet: Kafka has refused to guess, and someone must now choose between availability and data. Interviewers ask it to see whether we understand exactly what each option costs, including the less obvious consequences such as reused offsets, and whether we treat it as a business decision rather than a button. In this answer, we will recap how the partition got here, describe what clients experience, walk through waiting and unclean election in detail, look at what happens if the old replica returns, and see how to decide.
1A Quick Recap of How We Got Here
The partition has two live replicas listed, but only one was in the ISR, the in-sync replica set. The other was removed an hour ago because it fell behind, and it is now about 30,000 records short. With acks=all and min.insync.replicas=1, or with acks=1, the leader kept accepting writes even though it was the only in-sync replica, so those 30,000 records exist only on its disk. Then that disk failed.
unclean.leader.election.enable=false, the default, means only an ISR member may become leader. Its purpose is exactly this moment: to stop Kafka from silently electing a replica that is missing committed data. The only ISR member is gone, so there is no eligible leader.
2What Clients Experience Right Now
The partition is offline. It has no leader, and the controller reports it in OfflinePartitionsCount, a metric that should always be zero. Producers sending to this partition cannot find a leader; they retry until delivery.timeout.ms expires and then fail the sends. A producer using a key-based partitioner keeps choosing this partition for the same keys, so those keys cannot be written at all.
Consumers assigned this partition stop receiving data from it. Other partitions of the topic work normally, so consumer lag grows only for this partition, and anything that needs strict order per key across all partitions, such as a join, may stall downstream.
3Option One: Wait or Restore the Data
The safe option is to bring the lost replica back: repair the broker and hope the disk data is intact, or restore its log directory from a disk snapshot or backup if one exists. When that broker comes back with its log, it is still the last ISR member, so it becomes leader with all its data, the stale replica catches up from it, and nothing is lost.
The cost is time. The partition is unavailable for as long as the repair takes, minutes for a broker restart, hours or more for a disk replacement and restore, and possibly forever if the disk is truly lost. While we wait, producers fail for this partition, and we must decide whether upstream systems can buffer or retry for that long.
4Option Two: Unclean Leader Election
The fast option is to allow the out-of-sync replica to lead. We can trigger it directly with kafka-leader-election.sh, or enable unclean.leader.election.enable on the topic so the controller is allowed to choose it; in KRaft the explicit election is the most predictable way, and whether a config change triggers an election by itself has varied between versions, so check yours.
| Wait or restore | Unclean election | |
|---|---|---|
| Availability | offline until repaired | back within seconds |
| Data | nothing lost | 30,000 records lost |
| Offsets | unchanged | lost offsets reused by new records |
| Downstream | delayed but consistent | may hold records the log lost |
| Follow-up | none | reconcile from the source |
The partition is available again within seconds. The cost is the 30,000 records, offsets 2,400,118 to 2,430,117, that existed only on the dead replica. They are gone from the log. Producers that received acknowledgements for them were told the writes succeeded.
5If the Old Replica Comes Back Later
Suppose we chose the unclean election and the failed broker's disk turns out to be readable after all. When it rejoins, it becomes a follower of the new leader. Using leader epochs, it finds where its log diverges from the new leader's, which is at offset 2,400,118, and truncates everything after that point. The 30,000 records are deleted from it too.
Worse, the new leader has been accepting writes since the election, so offsets 2,400,118 onward now hold different records. Any consumer that had read some of the lost records before the failure has processed data that is no longer in the log, and if it committed an offset like 2,410,000, that offset now points to a different record. Its state, such as a database it updated or an aggregate it computed, no longer matches what the log says. This is why an unclean election is followed by reconciliation: comparing downstream systems with the source of truth and repairing differences.
6How to Decide
The decision depends on the topic's value. For metrics or logs, availability is worth far more than 30,000 lost data points, and unclean election is the obvious choice. For financial or order data, losing records may be unacceptable, and waiting or restoring is better even if it takes hours, possibly with producers buffering upstream. The decision should be the topic owner's, made with the on-call engineer, and recorded.
The better answer is to have made it in advance. A per-topic policy saying whether unclean election is acceptable, and settings that prevent the situation, replication factor 3 with min.insync.replicas=2 so a single remaining ISR member cannot accept writes alone, mean that nobody has to decide under pressure in the middle of the night.
7Follow-up questions
How would you find out which downstream systems saw the lost records?
First identify the lost range, offsets 2,400,118 to 2,430,117 on that partition, from the logs or from the old replica if it can be read. Then check each consumer group's committed offsets and its own logs or stores for that range: any group whose committed offset was beyond 2,400,118 before the failure read some of the lost records. Systems that store the source offset with each processed record make this precise. Finally, compare those systems with the source of truth, for example the producing service's database or outbox, to repair them.
Could this have been prevented?
Mostly yes. With min.insync.replicas=2 and acks=all, the leader would have refused writes once the follower left the ISR, so the 30,000 records would never have been acknowledged on a single broker. We would also have been alerted by UnderMinIsrPartitionCount an hour before the disk failed.
Does the producer learn that its records were lost?
No. It received successful acknowledgements before the failure, so nothing tells it later. Only reconciliation against the producer's own records reveals the gap.
8Conclusion
In this answer, we saw that when the only ISR member dies with unclean election disabled, the partition goes offline, producers fail and consumers stall. Waiting or restoring the dead replica loses nothing but keeps the partition unavailable, while an unclean election restores service immediately and loses the 30,000 records only that replica held. A returning old replica then truncates to the new leader, new records reuse the lost offsets, and downstream systems may hold data the log no longer has, so the decision belongs to the topic owner, ideally agreed in advance, followed by reconciliation if unclean election is used.
Open with
Right now the partition is offline. The only in-sync replica died, the other replica is out of the ISR and 30,000 records behind, and with unclean leader election disabled the controller will not elect it, so OfflinePartitionsCount goes above zero, producers to that partition retry until their delivery timeout and then fail, and consumers of it stall.
Then, if they want more
I have two options. The first is to wait for the failed broker or restore its data from a disk snapshot or backup. Nothing is lost, because that replica comes back as leader with everything, but the partition stays down until then, which could be hours.
The second is an unclean election, using kafka-leader-election.sh with election type UNCLEAN, or enabling the topic config. The stale replica becomes leader within seconds, but the 30,000 records that only lived on the dead disk are gone, even though producers were told they were written.
If the old replica returns later, it truncates to the new leader, and new records reuse those offsets, so a consumer that already processed some of the lost records holds state the log no longer matches.
I would make the decision with the topic owner based on the data's value, record it, and if we go unclean, reconcile downstream systems from the source. Long term, min.insync.replicas of 2 would have stopped writes before this situation could happen.
About this answer
- Last updated
- 13 November 2026
- 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 "The topic has unclean.leader.election.enable=false. What happens now, what are your...": https://scrivio-interview-library.netlify.app/spring-boot/kafka-internals/fb5ff6a40d/