Skip to main content
Interactive kafka-durability Configurator →Open Architecture Blueprint ↗
P0 INCIDENTL6 BARM07 · 6 MIN READ

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.

PRODUCTION SYMPTOM & ALERT SIGNATURE

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 > 0
01 · ROOT-CAUSE MECHANICS (WHY IT HAPPENS)

When 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.

02 · LIVE TRIAGE COMMANDS (COPY & RUN)
List every partition currently below min.insync.replicas
$ kafka-topics.sh --bootstrap-server kafka:9092 --describe --under-min-isr-partitions
Smoking gun: Partitions showing Replicas count = 2 and Isr count = 1.
Inspect topic durability configuration overrides
$ kafka-configs.sh --bootstrap-server kafka:9092 --entity-type topics --entity-name payments.events --describe
Smoking gun: min.insync.replicas=2 paired with replication.factor=2.
Check broker ISR shrink/expand rate for GC pauses or network saturation
$ curl -s http://kafka-exporter:9308/metrics | grep -E "under_replicated|isr_shrinks"
Smoking gun: Spiking isr_shrinks_total indicating slow follower fetch or replica.lag.time.max.ms breach.
03 · PRODUCTION DIFF (BROKEN VS HARDENED)
BROKEN · Broken Topic & Producer Config (zero fault tolerance during 1-broker restart)
# Topic created with RF=2 and min.isr=2 -> 1 broker restart = 100% write outage!
replication.factor=2
min.insync.replicas=2
unclean.leader.election.enable=true   # DANGER: Allows out-of-sync follower to overwrite committed data!

# Producer
acks=1                                # Incompatible with enable.idempotence=true
HARDENED · Production Zero-Data-Loss Durability Triad (survives 1 broker failure cleanly)
# Broker / Topic Durability Contract
default.replication.factor=3
min.insync.replicas=2
unclean.leader.election.enable=false  # Never elect an out-of-ISR replica

# Producer (Exactly-Once / Zero-Loss Write Path)
acks=all
enable.idempotence=true
max.in.flight.requests.per.connection=5
delivery.timeout.ms=120000
04 · MINUTE-24 BAR-RAISER CHECKPOINT (L6 · M07)TEST YOUR INSTINCT · ZERO SIGNUP

You need zero committed data loss AND zero write downtime during single-broker rolling upgrades across 3 AZs. Which Kafka configuration satisfies both invariants?

05 · POST-FIX VERIFICATION CHECKLIST
  • 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.
06 · FREQUENTLY ASKED ENGINEERING QUESTIONS

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.