Kafka NotEnoughReplicasException During Rolling Broker Upgrades
Prevent Kafka producer stalls during rolling upgrades by aligning replication.factor, min.insync.replicas, acks=all, and unclean.leader.election.enable.
The moment a single Kafka broker restarts for an OS patch, payment producers halt with org.apache.kafka.common.errors.NotEnoughReplicasException and checkout error rate hits 100%.
kafka_server_replicamanager_underreplicatedpartitions > 0 AND kafka_server_replicamanager_underminisrpartitioncount > 0When a topic is created with replication.factor=2 and min.insync.replicas=2, losing even 1 broker drops the In-Sync Replica (ISR) set to 1 — strictly below min.insync.replicas.
Any producer configured with acks=all (mandatory when enable.idempotence=true) is immediately rejected by the partition leader with NotEnoughReplicasException until the restarted broker catches up.
Lowering acks=1 or enabling unclean.leader.election.enable=true restores writes at the cost of silent committed-message data loss during leader failover.
You need zero committed data loss AND zero write downtime during single-broker rolling upgrades across 3 AZs. Which Kafka configuration satisfies both invariants?
- Confirm every critical topic has replication.factor=3 (spread across 3 availability zones) and min.insync.replicas=2.
- Verify kafka-topics.sh --under-min-isr-partitions returns 0 lines during a controlled single-broker rolling restart.
- Confirm unclean.leader.election.enable=false across all financial and state-mutating topics.
Can I use enable.idempotence=true with acks=1 in Kafka?
No. Modern Kafka clients throw a ConfigException on startup because idempotent sequence-number guarantees require acks=all.
Does max.in.flight.requests.per.connection=5 cause reordering with idempotence enabled?
No. With enable.idempotence=true, brokers buffer up to 5 in-flight batches per producer epoch and enforce strict sequence ordering.
How do I safely upgrade an existing RF=2 topic to RF=3 without downtime?
Use kafka-reassign-partitions.sh with a throttle (--throttle) to add a third replica per partition across a third AZ, wait for ISR sync, then remove the throttle.