Quick revision
The short answer
Because the broker has several log directories, Kafka treated the I/O errors as the failure of one directory, not of the broker: it took the replicas in /data3 offline on that broker, told the controller, and the controller moved leadership of the affected partitions to other in-sync replicas, which is why about 300 partitions are under-replicated while the process keeps running. Most clients see only a brief leader change and a retry; partitions whose only in-sync replica was on /data3 go offline, and acks=all writes fail where the ISR is now below min.insync.replicas. We recover by replacing the disk and restarting the broker, then letting the partitions re-replicate under a throttle.
What to remember
In this answer, we saw that a broker with several log directories isolates a failed one: replicas in /data3 go offline on that broker, the controller learns of it and moves leadership to other in-sync replicas, and the process keeps running. Most clients see a leader change and a retry, while partitions that were already weak go offline or reject acks=all writes. We recover by replacing the disk and restarting, letting the replicas re-replicate under a throttle, and we prevent outages with replication factor 3, min.insync.replicas=2 and alerts on OfflineLogDirectoryCount.
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.
Because the broker has several log directories, Kafka treated the I/O errors as the failure of one directory, not of the broker: it took the replicas in /data3 offline on that broker, told the controller, and the controller moved leadership of the affected partitions to other in-sync replicas, which is why about 300 partitions are under-replicated while the process keeps running. Most clients see only a brief leader change and a retry; partitions whose only in-sync replica was on /data3 go offline, and acks=all writes fail where the ISR is now below min.insync.replicas. We recover by replacing the disk and restarting the broker, then letting the partitions re-replicate under a throttle.
Why this question is asked
Disk failures are the most common hardware fault in a Kafka cluster, and with JBOD, several independent disks rather than one RAID volume, they no longer have to take a whole broker down. But the behaviour surprises people: the broker is running, its health check is green, and yet hundreds of partitions are under-replicated. Interviewers ask this to see whether we understand what Kafka does on a log directory failure, what that means for clients, and how to recover without causing a second incident. In this answer, we will recap how JBOD works in Kafka, follow what the broker and controller did, look at the impact partition by partition, recover step by step, and set things up so one disk never makes data unavailable.
1A Quick Recap: JBOD and Log Directories
A broker stores its data in the directories listed in log.dirs. With JBOD we list one directory per physical disk, for example /data1 to /data4, and the broker places each partition replica entirely in one of them. There is no striping or mirroring: if /data3 dies, the replicas stored in /data3 are gone from this broker, but the replicas in the other three directories are untouched.
Redundancy therefore comes from Kafka replication, not from the disk layer. With replication factor 3, every partition in /data3 has two more copies on other brokers. That is what lets Kafka treat a disk as a small, replaceable unit.
2What Kafka Did When /data3 Failed
When a read or write in /data3 threw an I/O error, the broker raised KafkaStorageException and marked the whole directory offline. It stopped serving every replica in that directory, which is the message about stopping serving replicas in dir /data3, and OfflineLogDirectoryCount became 1. It did not stop the process, because the other three directories are healthy and their replicas can keep working.
The broker then reported the failed directory to the controller. In KRaft clusters, JBOD is supported from Kafka 3.7 onward with directory ids: each log directory has an id, the controller knows which directory holds each replica, and the broker reports a failed directory so the controller can act on exactly those partitions (KIP-858). The details and their maturity changed across 3.7, 3.8 and 4.x, so check your version's notes. The controller removed this broker from the ISR of the affected partitions and elected new leaders from the remaining in-sync replicas where this broker had been the leader.
7 messages in order. Play them, or step through them one at a time.
The broker keeps running and keeps serving the replicas in its healthy directories.
Notice one important difference: a broker with a single log directory has nothing left to serve when that directory fails, so it shuts down instead. The partial-failure behaviour is a feature of having several directories.
3What Clients See, Partition by Partition
The impact depends on the state of each partition before the failure. For most partitions, the replica on /data3 was one of three in-sync copies. If it was a follower, the partition now has an ISR of two; with min.insync.replicas=2 it still accepts acks=all writes, and clients notice nothing. If it was the leader, clients get a NOT_LEADER_OR_FOLLOWER error once, refresh their metadata and retry against the new leader, which shows up as a short latency spike.
The bad cases are partitions that were already weak. If a partition's only in-sync replica was on /data3, perhaps because the other replicas were lagging or on a broker in maintenance, it has no eligible leader and goes offline. If a partition was at an ISR of two and lost one, it now has one, below min.insync.replicas, so acks=all producers fail with NotEnoughReplicasException while consumers can still read.
| State before the failure | After /data3 fails | Client effect |
|---|---|---|
| ISR 3, follower on /data3 | ISR 2, under-replicated | None |
| ISR 3, leader on /data3 | New leader elected | One retry, brief latency |
| ISR 2, one replica on /data3 | ISR 1, under min ISR | acks=all writes fail |
| Only in-sync replica on /data3 | No eligible leader | Partition offline |
4Recovering the Broker
A failed directory does not come back by itself. Even after the disk is replaced, the broker only scans log.dirs at startup, so the directory returns only after a restart. The steps are: replace the disk, mount and format it at the same path with the right ownership, and restart the broker with a controlled shutdown. On a KRaft broker, the new empty directory must be formatted with kafka-storage.sh so it gets its metadata file and directory id; check the format command your version expects.
When the broker starts, the partitions that lived in /data3 have no local data, so the broker re-creates them and fetches everything from the current leaders. For 300 partitions that can be terabytes, which would compete with producer traffic, so we set a replication throttle first and remove it when catch-up is done.
We watch UnderReplicatedPartitions fall to 0 before touching any other broker. The throttle trades recovery time for stability: at 100 MB/s, 3 TB takes about eight and a half hours, during which these partitions have one less copy, so we pick the highest rate the cluster can absorb without hurting producers.
5Making Sure One Disk Never Makes Data Unavailable
The partitions that went offline or under min ISR were already unhealthy before the disk failed. So the prevention is to keep every partition at full strength: replication factor 3 with min.insync.replicas=2 everywhere, and a habit of fixing under-replication quickly rather than living with it. With that, one disk failure always leaves two in-sync copies and nothing stops.
We also alert on OfflineLogDirectoryCount above 0, which pages, and on the earlier warning signs: kernel I/O errors and SMART failure predictions from the host, and rising disk latency. Catching a dying disk before it fails lets us move its replicas away calmly with a reassignment instead of reacting at night.
6Follow-up questions
Why not use RAID 10 instead of JBOD?
RAID hides a disk failure from Kafka and keeps the broker fully healthy, which is simpler to operate, but it halves usable capacity and a rebuild can slow the broker for hours. JBOD uses all the disk space and relies on Kafka's own replication, which we already pay for. Many teams pick JBOD for cost; teams that want the fewest moving parts pick RAID or cloud volumes that are already replicated.
Can we move the replicas out of /data3 without restarting?
Not while the directory is offline, because the data cannot be read. We can reassign those partitions to other brokers with kafka-reassign-partitions.sh, which copies them from the leaders, but if the disk will be replaced soon, restarting the broker with the new disk is usually simpler. Moving replicas between healthy directories of one broker is possible with the log-dir option of a reassignment.
Does the broker ever give up and shut down?
Yes. If every log directory fails, or the directory holding critical broker state fails, the broker shuts down because it has nothing it can serve. With a single log directory, any disk failure shuts it down.
7Conclusion
In this answer, we saw that a broker with several log directories isolates a failed one: replicas in /data3 go offline on that broker, the controller learns of it and moves leadership to other in-sync replicas, and the process keeps running. Most clients see a leader change and a retry, while partitions that were already weak go offline or reject acks=all writes. We recover by replacing the disk and restarting, letting the replicas re-replicate under a throttle, and we prevent outages with replication factor 3, min.insync.replicas=2 and alerts on OfflineLogDirectoryCount.
Open with
Since the broker has four log directories, Kafka treated this as the failure of one directory, not of the broker. On the I/O error it raised KafkaStorageException, marked /data3 offline and stopped serving the replicas in it, which is why OfflineLogDirectoryCount is one.
Then, if they want more
It reported the failed directory to the controller; in KRaft that works from 3.7 with directory ids under KIP-858, and I would check the version notes for its maturity. The controller shrank the ISRs and moved leadership of partitions led from that disk to other in-sync replicas. That gives the 300 under-replicated partitions while the process keeps running.
If the broker had only one log directory, it would have shut down instead. For clients, most partitions just see a leader change and a retry. The risk is partitions that were already weak: if the only in-sync replica was on /data3 the partition goes offline, and if the ISR drops below min.insync.replicas, acks=all producers get NotEnoughReplicas.
To recover, I replace the disk, format it at the same path and restart the broker, because the directory only comes back on restart. Its partitions then re-replicate from the leaders, so I set a replication throttle and watch UnderReplicatedPartitions go back to zero, then run a preferred leader election.
Going forward, replication factor three with min ISR two and an alert on OfflineLogDirectoryCount make one disk a non-event.
About this answer
- Last updated
- 13 November 2026
- Versions it names
- Kafka 3.7
- 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 broker log shows KafkaStorageException and a message about stopping serving replicas...": https://scrivio-interview-library.netlify.app/spring-boot/kafka-operations/13b6f79948/