Learn Labs
Operations

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.

#FailureSymptomWhere to lookFix
1Broker down (reproduced)Under-replicated partitions; leaders move--under-replicated-partitions; dashboardRestart it; it catches up and rejoins the ISR
2ISR below min.insync (reproduced)NOT_ENOUGH_REPLICAS on acks=all produce--describe ISR columnRestore brokers; never "fix" by lowering min.insync.replicas mid-incident unless you accept the risk
3Controller quorum lost (reproduced)Nothing changes: no elections, admin tools hangkafka-metadata-quorum.shRestore a majority of controllers; use dedicated controllers
4Leadership imbalance (reproduced)One broker hot after recoveriesLeader count per brokerPreferred leader election
5Rebalance stormLag climbs; groups keep rebalancingGroup state; consumer logsFix slow processing / max.poll.interval.ms; static membership; KIP-848
6Consumer lag past retentionData silently skipped (auto.offset.reset)Lag vs retention; offsets jumpScale consumers, raise retention, alert on lag age
7Hot partitionOne partition's lag and one broker's load far above othersLag by partition; bytes in by brokerBetter keys; more partitions only helps if keys spread
8Disk fullBroker crashes or goes offline; partitions offlineDisk metrics, kafka-log-dirs.shRetention, more disk, reassign; alert at 70-80%
9Advertised listener misconfigBootstrap works, then every produce times outClient logs show unresolvable hostsCorrect advertised.listeners per network
10Producer silently droppingRecords missing; no errors visibleNo delivery callbacks / no flush()Handle callbacks, flush() on shutdown, alert on record-error-rate
11Duplicate processing (reproduced)Records processed twice after a crashDownstream duplicatesIdempotent consumers; transactions for Kafka→Kafka
12Aborted transaction data read (reproduced)Consumers see records from rolled-back transactionsConsumer isolation.levelread_committed everywhere it matters
13Schema break (reproduced, prevented)Consumers fail to deserialize after a deployRegistry compatibilityRegistry with BACKWARD(_TRANSITIVE); register in CI
14CDC slot filling diskPostgres disk grows while a connector is stoppedpg_replication_slots retained WALRestart or remove connector and drop the slot
15Quota throttling (reproduced)One client's latency jumps to secondsBroker throttle-time metricsRaise 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)?

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=300000

For each, note what alerted first, how long recovery took, and what a human had to do.

On this page