---
title: "KafScale 2.1: a Kafka producer timeout that still wrote"
description: "KafScale 2.1: etcd fails after the S3 upload, the producer gets REQUEST_TIMED_OUT, the next restore adopts the segment, and the retry makes a duplicate."
url: https://monedula.dev/kafka-simulator/scenarios/kafscale-2-failed-etcd-write/
---

# KafScale 2.1: a Kafka producer timeout that still wrote

Scenario 08.2.5 · KafScale: a failed etcd write after a good upload. Diskless · Advanced · about 3 min · Apache Kafka 4.4 · KafScale 2.1.

KafScale 2.1 · etcd stops between the S3 upload and the etcd write: the producer gets REQUEST_TIMED_OUT, the segment stays in S3, the next restore adopts it, and the retry writes the record a second time.

Run it: https://monedula.dev/kafka-simulator/playground/?scenario=08.2.5

## What you start with

A KafScale produce request becomes one S3 segment, then the broker writes the partition's new end offset to etcd. The producer is acked only after that etcd write succeeds. If the write fails after a good upload, the producer gets an error, the segment stays in S3, and the broker drops the partition from memory, so the next request for it restores from etcd and S3 first. Here etcd stops during order-2's etcd write and starts again 2 s later. Producer p1 has idempotence off and is set to retries=30 and retry.backoff.ms=500. Watch the segment in the object storage lane, etcd, p1's errors and what c1 reads.

## Step by step

1. **order-2 is uploading** (t+1.360s): orders is a KafScale topic (KafScale 2.1) with one partition, owned by broker-2. order-1 was acked at 790 ms and c1 read it at 1000 ms. p1 sent order-2 at 1300 ms: broker-2 gave it offset 1 and started uploading segment orders/0/segment-00000001 at 1350 ms. After the upload, broker-2 writes the new end offset to etcd, and only then acks. [Open at this step](https://monedula.dev/kafka-simulator/playground/?scenario=08.2.5&t=0)
2. **etcd stops during the etcd write: not acked** (t+1.995s): The upload landed at 1950 ms and the etcd write began; etcd stopped at 1970 ms and the write failed at 1990 ms. p1 got REQUEST_TIMED_OUT, not an ack: in KafScale the etcd write gates the ack. The segment stays in S3, marked failed; the end offset in etcd is still 1, so c1 cannot read it. broker-2 dropped the partition from memory: the next request for it restores first. [Open at this step](https://monedula.dev/kafka-simulator/playground/?scenario=08.2.5&t=1)
3. **etcd is back** (t+4.100s): While etcd was down, p1's retries at 2490, 2990, 3490 and 3990 ms got REQUEST_TIMED_OUT, and so did c1's offset commit and its fetches: broker-2 had dropped the partition from memory, and loading it again needs etcd. etcd started at 4000 ms. broker-2 still holds the lease, but has no next offset in memory for orders-0. [Open at this step](https://monedula.dev/kafka-simulator/playground/?scenario=08.2.5&t=2)
4. **The retry restores and adopts the failed segment** (t+4.500s): p1's retry at 4490 ms made broker-2 restore orders-0 before appending: etcd's end offset is 1, but S3 lists the failed segment, which ends at offset 1, so S3's end is 2. The restore adopts it and numbering goes on from 2: order-2 at offset 1 is now readable, although p1 was told it failed. The retry itself is a new record: offset 2, uploading. [Open at this step](https://monedula.dev/kafka-simulator/playground/?scenario=08.2.5&t=3)
5. **c1 reads order-2 twice** (t+6.050s): c1 read offset 1, the first copy of order-2, at 5000 ms, from S3. The retry was acked at 5130 ms, and c1 read offset 2, the second copy, at 6000 ms. p1 sent two records and was acked for two; the partition holds three. KafScale has no idempotent producer, so nothing drops the duplicate. KafScale's maintainers confirmed this is intended: the segments in S3 are authoritative, and delivery is at-least-once. [Open at this step](https://monedula.dev/kafka-simulator/playground/?scenario=08.2.5&t=4)

## The takeaway

p1 was told the write failed, but the record was not gone. Its segment stayed in S3, and when etcd was back, p1's retry made broker-2 restore the partition: the restore found the segment, took it in and wrote its end offset to etcd, so order-2 became readable at offset 1. Then the retry wrote order-2 again, at offset 2, and was acked. c1 read order-2 twice. p1 runs with idempotence off. Since KafScale 2.1.0 an idempotent producer's retry gets offset 1 back instead, because the restore rebuilds its sequences from the segments in S3; without idempotence, KafScale's operations docs say a timeout does not prove that nothing was written: after a producer timeout, a record can reach consumers twice. KafScale's maintainers confirmed this is intended: the segments in S3 are authoritative, so a restore moves the end offset in etcd forward to match them, and delivery is at-least-once. Simulator choices: the etcd write fails when it would have ended (KafScale waits up to 3 s), the brokers notice the outage at once, and only the REQUEST_TIMED_OUT case is shown (other etcd server errors answer UNKNOWN_SERVER_ERROR and are not modelled).

## Configs in this scenario

- [`retries`](https://kafka.apache.org/44/configuration/producer-configs/#producerconfigs_retries): How many times the producer sends a batch again after a transient error (default 2147483647, so in practice delivery.timeout.ms ends the retrying); idempotence needs it above 0.
- [`retry.backoff.ms`](https://kafka.apache.org/44/configuration/producer-configs/#producerconfigs_retry.backoff.ms): How long the producer waits before retrying a failed send, so it does not hammer a broker that is still recovering.

## Further reading

- [KafScale v2.1.0 source on GitHub](https://github.com/KafScale/platform/blob/v2.1.0/docs/operations.md)

## Troubleshooting

- [TimeoutException in Kafka producers: causes and fixes](https://monedula.dev/kafka/troubleshooting/producer-timeout-exception/)
- [Kafka duplicate messages: causes and fixes](https://monedula.dev/kafka/troubleshooting/duplicate-messages/)
