Monedula

Scenario 01.3.1 · Idempotence retry

Kafka idempotent producer: retrying NOT_ENOUGH_REPLICAS

Producers & EOS · Intermediate · about 2 min · Apache Kafka 4.3

An idempotent acks=all produce retries through NotEnoughReplicas and commits exactly once.

Run this scenario in the playground

Stable - record committed at offset 0. t+10.000s

Open at this step: step 5, Stable - record committed at offset 0

What you start with

With two brokers down the ISR is below min.insync.replicas, so an acks=all produce is rejected with NOT_ENOUGH_REPLICAS. NOT_ENOUGH_REPLICAS is retriable, so the producer retries with backoff within delivery.timeout.ms, and idempotence keeps those retries free of duplicates; once a broker restarts and the ISR recovers the write commits exactly once.

Step by step

  1. Cluster ready - acks=all, idempotence on t+0.000s Open at this step: step 1, Cluster ready - acks=all, idempotence on
  2. Two brokers down - ISR shrinks to 1 (below min.ISR) t+5.100s Open at this step: step 2, Two brokers down - ISR shrinks to 1 (below min.ISR)
  3. Produce hits NotEnoughReplicas - retrying t+7.100s NOT_ENOUGH_REPLICAS is retriable, so the producer keeps retrying; idempotence makes each retry safe. Open at this step: step 3, Produce hits NotEnoughReplicas - retrying
  4. broker-2 back - the in-flight retry commits exactly once t+8.300s No duplicate: the same record lands at offset 0 once the cluster heals. Open at this step: step 4, broker-2 back - the in-flight retry commits exactly once
  5. Stable - record committed at offset 0 t+10.000s Open at this step: step 5, Stable - record committed at offset 0

The takeaway

An idempotent acks=all producer turns a transient NOT_ENOUGH_REPLICAS into a safe retry: the record commits once the ISR heals, with no loss and no duplicate.

Configs in this scenario

Embed this scenario

Paste this into a blog post, a course page or your team's docs. The scenario plays inside your page, and the link under it points readers to this walkthrough.

<iframe src="https://monedula.dev/kafka-simulator/embed/?scenario=01.3.1" title="Kafka Simulator: Idempotence retry" width="100%" height="520" style="border:1px solid #d0d0d0;border-radius:8px" loading="lazy"></iframe>
<p><a href="https://monedula.dev/kafka-simulator/scenarios/idempotence-retry/">Kafka idempotent producer: retrying NOT_ENOUGH_REPLICAS</a></p>

Further reading

Apache Kafka documentation

Troubleshooting

More in Producers & EOS

All scenarios