Failure Scenarios
How Kafka systems break in production, and how each looks
Several of these were reproduced while building this module, and are marked as such.
| # | Failure | Symptom | Where to look | Fix |
|---|---|---|---|---|
| 1 | Broker down (reproduced) | Under-replicated partitions; leaders move | --under-replicated-partitions; dashboard | Restart it; it catches up and rejoins the ISR |
| 2 | ISR below min.insync (reproduced) | NOT_ENOUGH_REPLICAS on acks=all produce | --describe ISR column | Restore brokers; never "fix" by lowering min.insync.replicas mid-incident unless you accept the risk |
| 3 | Controller quorum lost (reproduced) | Nothing changes: no elections, admin tools hang | kafka-metadata-quorum.sh | Restore a majority of controllers; use dedicated controllers |
| 4 | Leadership imbalance (reproduced) | One broker hot after recoveries | Leader count per broker | Preferred leader election |
| 5 | Rebalance storm | Lag climbs; groups keep rebalancing | Group state; consumer logs | Fix slow processing / max.poll.interval.ms; static membership; KIP-848 |
| 6 | Consumer lag past retention | Data silently skipped (auto.offset.reset) | Lag vs retention; offsets jump | Scale consumers, raise retention, alert on lag age |
| 7 | Hot partition | One partition's lag and one broker's load far above others | Lag by partition; bytes in by broker | Better keys; more partitions only helps if keys spread |
| 8 | Disk full | Broker crashes or goes offline; partitions offline | Disk metrics, kafka-log-dirs.sh | Retention, more disk, reassign; alert at 70-80% |
| 9 | Advertised listener misconfig | Bootstrap works, then every produce times out | Client logs show unresolvable hosts | Correct advertised.listeners per network |
| 10 | Producer silently dropping | Records missing; no errors visible | No delivery callbacks / no flush() | Handle callbacks, flush() on shutdown, alert on record-error-rate |
| 11 | Duplicate processing (reproduced) | Records processed twice after a crash | Downstream duplicates | Idempotent consumers; transactions for Kafka→Kafka |
| 12 | Aborted transaction data read (reproduced) | Consumers see records from rolled-back transactions | Consumer isolation.level | read_committed everywhere it matters |
| 13 | Schema break (reproduced, prevented) | Consumers fail to deserialize after a deploy | Registry compatibility | Registry with BACKWARD(_TRANSITIVE); register in CI |
| 14 | CDC slot filling disk | Postgres disk grows while a connector is stopped | pg_replication_slots retained WAL | Restart or remove connector and drop the slot |
| 15 | Quota throttling (reproduced) | One client's latency jumps to seconds | Broker throttle-time metrics | Raise or remove the quota, or reduce that client's load |
Reading the signals
"Producers are timing out." Check, in order: are brokers up (up)? Is
the ISR below min.insync.replicas (NOT_ENOUGH_REPLICAS in the error)?
Are brokers saturated (request handler idle ratio low, produce p99 high)?
Are clients being throttled (quotas)? Can the client resolve every
advertised listener?
"Consumers are behind." Is lag growing for every partition (consumers
too slow: scale them, up to the partition count) or one partition (hot key
or one stuck consumer)? Is the group rebalancing constantly (check group
state and consumer logs for max.poll.interval.ms)? Did a deploy change
processing time?
"Data is missing." Was it ever acknowledged (producer errors, acks
setting)? Was it consumed past (auto.offset.reset after lag exceeded
retention)? Was it in an aborted transaction? Did an unclean leader election
happen (it's off here, but check broker logs)?
Most real Kafka incidents start with a consumer, not a broker: a slow deploy, a poison message that crashes the consumer on every retry, a rebalance loop. Broker failures in a correctly configured cluster (RF 3, min ISR 2, dedicated controllers) are mostly non-events. Put the most monitoring effort into lag.
Game day
# keep lag.py running throughout
docker compose -f compose_prod.yaml run --rm labs python lag.py
docker stop kafka-3 # 1. broker down
docker stop kafka-2 # 2. ISR below min.insync (and quorum lost)
docker start kafka-2 kafka-3 # 3. recovery; then check leader balance
docker pause connect # 4. CDC stalled: watch the replication slot
# 5. poison message: produce a record your consumer can't parse, and watch it crash-loop
# 6. rebalance storm: add time.sleep(400) per record in a consumer with max.poll.interval.ms=300000For each, note what alerted first, how long recovery took, and what a human had to do.