Kafka Offline Partitions
An offline partition has no leader and cannot serve normal reads or writes. Prioritize recovery of the last in-sync replicas.
Capture State
Section titled “Capture State”kafka-topics.sh --bootstrap-server kafka:9092 \ --describe --unavailable-partitions
kafka-topics.sh --bootstrap-server kafka:9092 \ --describe --topic orders
kafka-log-dirs.sh --bootstrap-server kafka:9092 \ --describe --topic-list ordersRecord the assigned replicas, ISR, last leader, broker/rack availability, directory errors, and incident timeline. Preserve logs from every assigned broker.
Diagnose
Section titled “Diagnose”- Determine whether all assigned replicas are down or only unable to register.
- Check broker processes, controller quorum, broker registration, listeners, and inter-broker security.
- Check the specific log directories, mounts, capacity, permissions, and kernel I/O errors.
- Identify correlated rack, zone, network, or deployment failures.
- Establish which replica has the newest trustworthy log before considering data-loss recovery.
Recover Without Data Loss
Section titled “Recover Without Data Loss”- Restore an existing ISR broker or its storage.
- Restore controller-to-broker and broker-to-broker communication.
- Bring failed log directories back only after fixing the underlying mount or device problem.
- Wait for the controller to elect an eligible leader and verify leader epoch movement.
Last-Resort Unclean Election
Section titled “Last-Resort Unclean Election”kafka-leader-election.sh --bootstrap-server kafka:9092 \ --election-type UNCLEAN \ --topic orders --partition 7Danger
An unclean election can discard records that were acknowledged by the previous leader but absent from the elected replica. Require explicit data-loss approval, record replica offsets, and retain the failed replicas for investigation.
Verify
Section titled “Verify”- The unavailable-partition query returns no affected partition.
- Produce and fetch succeed for the recovered partition.
- ISR expands to the intended replication factor.
- No failed log directory remains hidden behind the recovered leader.
- The application reconciles any accepted data-loss boundary.
Prevent Recurrence
Section titled “Prevent Recurrence”Spread replicas across independent failure domains, keep replication factor and min.insync.replicas aligned, monitor offline/under-min-ISR partitions, test broker recovery, and avoid simultaneous maintenance on all replicas.