Monedula

Kafka troubleshooting

Kafka partitions are under-replicated

Kafka symptom

A partition is under-replicated when its in-sync replica set (ISR) is smaller than its replica list: at least one follower is down or has not caught up with the leader for replica.lag.time.max.ms. Find the missing broker with kafka-topics.sh --describe --under-replicated-partitions and restart or repair it; the follower rejoins the ISR on its own once it has caught up.

Reproduce it in the playground

The moment it happensbroker-3 is killed outright. t+3.500s

One broker is gone. `kafka-topics --describe --under-replicated-partitions` now lists every partition that lost a copy, across both topics, and each row shows an ISR shorter than its replica list. `ssh broker-3` does not get that far: the machine itself is down, and the shell refuses from here without asking the cluster anything.

Open at this step: step 3, broker-3 is killed outright

What it means

Every partition has a leader and followers that fetch from it, and the ISR is the subset that is caught up. A follower leaves the ISR when its broker loses its session with the controller (broker.session.timeout.ms, 9 seconds by default) or when it has not fetched up to the leader's log end for replica.lag.time.max.ms (30 seconds by default). In the lagging case the leader logs the shrink, for example "[Partition orders-0 broker=1] Shrinking ISR from 1,2,3 to 1,2. Leader: (highWatermark: 120, endOffset: 130). Out of sync replicas: (brokerId: 3, endOffset: 100, lastCaughtUpTimeMs: 1760000000000)." The broker metric UnderReplicatedPartitions counts the partitions that broker leads whose ISR is shorter than the replica list, so add it up across brokers. Under-replicated means redundancy is reduced, not that writes fail: with replication factor 3 and min.insync.replicas 2, an ISR of two still accepts acks=all writes. Writes are refused only once the ISR drops below min.insync.replicas, which UnderMinIsrPartitionCount and kafka-topics.sh --describe --under-min-isr-partitions report. A partition with no leader at all is offline, and no broker counts it here because no broker leads it.

Likely causes, most common first

  1. A broker is down or restarting. When a broker stops, crashes or loses its controller session, every partition with a replica on it shrinks its ISR at the same moment, so the count jumps. A rolling restart produces the same pattern one broker at a time, and the count should return to zero after each broker has caught up.
  2. A follower cannot keep up. The broker is up, but its replica fetchers fall behind: slow or failing disks, a saturated network link, a leader overloaded with produce traffic, or too few fetcher threads (num.replica.fetchers, default 1). The ISR then shrinks and expands repeatedly, which shows as non-zero IsrShrinksPerSec and IsrExpandsPerSec. Outside broker restarts both should be 0.
  3. A replication throttle is too low or was left on. Partition reassignments usually run under a replication throttle. If the throttled rate is below the write rate into the partition, the throttled replicas never catch up, and the throttle is only removed when someone runs kafka-reassign-partitions.sh --verify after the move.

How to fix it

What not to do

Configs involved

Reproduce it in the simulator

Sources

Related

All troubleshooting pages