---
title: "AutoMQ diskless Kafka: a broker crash and WAL failover"
description: "AutoMQ 1.7.4: a killed broker loses its open acks=1 records; after 9 s the controller fences it and a peer replays its WAL, so partitions reopen at epoch 1."
url: https://monedula.dev/kafka-simulator/scenarios/automq-broker-crash-wal-failover/
---

# AutoMQ diskless Kafka: a broker crash and WAL failover

Scenario 09.1.2 · AutoMQ: a broker crashes and its WAL is replayed. Diskless · Advanced · about 4 min · Apache Kafka 4.4 · AutoMQ 1.7.4.

AutoMQ 1.7.4 · a killed leader keeps its partitions until the controller fences it, then a peer replays its WAL into an SSO and the partitions reopen elsewhere at epoch 1.

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

## What you start with

AutoMQ 1.7.4 is a fork of Apache Kafka 3.9.1 that keeps every topic in S3, with one leader and no other replica per partition. A broker answers acks=1 records as soon as they are appended in memory, and writes them to S3 as one WAL object only when its buffer closes. broker-1 leads orders-0 and orders-3 and will be killed while that buffer is open. Producer p-all sends acks=all and is set to retries=30 and retry.backoff.ms=500, which in the simulator, whose backoff is fixed, is about 15 s of retries, longer than the 9 s fence plus the failover. A real Kafka client retries until delivery.timeout.ms (120 s by default); the simulator's default of 5 retries would give up first. Producer p-one sends acks=1. Watch the controller lane, the WAL buffer and the partition strips.

## Step by step

1. **broker-1 leads two partitions, its WAL buffer is filling** (t+2.150s): The first round of records is safe: broker-1's WAL object wal-0001 was confirmed in S3 at 1250 (orders-0 and orders-3, offset 0), but it is still a WAL object, not yet an SSO. A second round was appended at 2050. On broker-1 it sits in the open WAL buffer: p-all's record on orders-0 (acks=all, no answer yet) and p-one's on orders-3 (acks=1, already answered). The other two brokers hold their own buffers. Producer p-all has retries=30 and retry.backoff.ms=500 so it can outlast what comes next. [Open at this step](https://monedula.dev/kafka-simulator/playground/?scenario=09.1.2&t=0)
2. **Broker-1 crashes: acks=1 records in its buffer are lost** (t+2.250s): broker-1 was killed without warning at 2200, before its buffer closed, so nothing of the second round reached S3. p-one's acks=1 record on orders-3 (offset 1) had already been answered and is now lost: 1 record, counted in the log. p-all's acks=all record on orders-0 was never answered; the request fails with REQUEST_TIMED_OUT and p-all starts retrying. The first round, confirmed in S3, is untouched. The dead leader's log end still reads 2 on both partitions, above the high watermark of 1: on orders-3 the extra entry is the lost acks=1 record, on orders-0 it is p-all's unanswered record, which p-all will retry. [Open at this step](https://monedula.dev/kafka-simulator/playground/?scenario=09.1.2&t=1)
3. **For 9 s the partitions keep their dead leader: produce times out** (t+10.800s): The KRaft controller fences a broker only after broker.session.timeout.ms, 9 s by default (AutoMQ 1.7.4), and the simulator does not shorten it. Until then orders-0 and orders-3 still name broker-1 as leader, so p-all's retries (each record retries every 500 ms) get REQUEST_TIMED_OUT, and so does its new record for orders-3. The partitions on broker-2 and broker-3 are unaffected: they take writes, confirm WAL objects, and became SSOs at 5890. [Open at this step](https://monedula.dev/kafka-simulator/playground/?scenario=09.1.2&t=2)
4. **The controller fences broker-1; its partitions have no leader** (t+11.200s): At the kill plus 9000 ms the controller fences broker-1 and retargets each partition it led: orders-0 now targets broker-2 and orders-3 broker-3, with no leader until they open. The target is the least-loaded live broker, same zone first (none here), ties by id: the simulator's stand-in for the controller's weighted random pick. The retries from p-all now get NOT_LEADER_OR_FOLLOWER. The lowest-numbered live broker, broker-2, starts the failover for broker-1 (the simulator's choice; AutoMQ picks the broker round-robin). [Open at this step](https://monedula.dev/kafka-simulator/playground/?scenario=09.1.2&t=3)
5. **Another broker replays broker-1's WAL into an SSO** (t+12.140s): broker-2 read broker-1's confirmed WAL object wal-0001 from S3 and wrote its contents as the SSO sso-0002, committed to the controller (marked failover): 940 ms in the simulator, a read of 300 ms plus the 600 ms upload and the 40 ms commit. Then both streams were closed. Only what was confirmed in S3 survives: the open buffer is gone, which is why the acks=1 record was lost. Epoch 0 of orders-0 and orders-3 is closed; the next epoch opens 100 ms later (the 100 ms is the simulator's poll interval). The dead leader's unconfirmed log end (2) will be discarded: 100 ms later the stream reopens at the confirmed end, 1. [Open at this step](https://monedula.dev/kafka-simulator/playground/?scenario=09.1.2&t=4)
6. **The partitions reopen elsewhere with epoch 1; retries are acked** (t+13.850s): At 12240 broker-2 opened orders-0 and broker-3 opened orders-3 at epoch 1, next offset 1 (the confirmed end of the replayed WAL). p-all's retries then went through: both were appended, uploaded and confirmed, and the two acks=all records were acked at 13650 and 13800 with offset 1 on each partition. The lost acks=1 record had used offset 1 on orders-3, and the new leader reused it: offsets stay unique because the lost record was never confirmed. [Open at this step](https://monedula.dev/kafka-simulator/playground/?scenario=09.1.2&t=5)
7. **The consumer reads on: no acks=all record lost** (t+15.600s): Consumer g1 read every record that was confirmed: 9 in total across the six partitions, 2 each on orders-0, orders-2 and orders-3 and 3 on orders-1. Of 10 records produced, all 5 acks=all records were acked and are readable; of the 5 acks=1 records, 4 are readable and 1 was acked, lost and never read. broker-1 stays fenced at epoch 0 and no partition has it as a leader any more. [Open at this step](https://monedula.dev/kafka-simulator/playground/?scenario=09.1.2&t=6)

## The takeaway

A hard-killed broker took its open WAL buffer with it: the one acks=1 record there had already been answered and was lost, while the records confirmed in S3 before the kill were kept. For the 9 s broker.session.timeout.ms (Kafka's default, not shortened here) the controller still named broker-1 as leader, so p-all's acks=all records got no answer and were retried. Then the controller fenced broker-1 and retargeted its partitions; a peer replayed broker-1's confirmed WAL object into an SSO and closed the streams, the targets opened them at epoch 1, and the retried acks=all records were acked. The new leaders started at the confirmed end of the WAL, so the lost record's offset was reused and offsets stayed unique. All 5 acks=all records were acked and read; 1 of the 5 acks=1 records was lost. Simulator choices: the failover takes 940 ms (a 300 ms read, the 600 ms upload and the 40 ms commit), the target is the least-loaded live broker, same zone first (none here), ties by id (a stand-in for the controller's weighted random pick), the failover is started by the lowest-numbered live broker (AutoMQ picks round-robin), the next epoch opens 100 ms after the close (the simulator's poll interval), unacked requests fail at the kill, and p-all's retry settings are chosen to outlast the fence.

## Configs in this scenario

- [`acks`](https://kafka.apache.org/44/configuration/producer-configs/#producerconfigs_acks): How many replicas must have a write before the producer counts it as sent: 0 (none), 1 (the leader only) or all (every in-sync replica, the default, and required for idempotence). [How acks works](https://monedula.dev/kafka/configs/acks/)
- [`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.
- [`delivery.timeout.ms`](https://kafka.apache.org/44/configuration/producer-configs/#producerconfigs_delivery.timeout.ms): The upper bound on reporting success or failure after send() returns, covering the wait in a batch, the wait for the acknowledgement and every retry (default 120000, 2 minutes); it should be at least request.timeout.ms plus linger.ms.
- [`broker.session.timeout.ms`](https://kafka.apache.org/44/configuration/broker-configs/#brokerconfigs_broker.session.timeout.ms): How long the registration of a KRaft broker lasts without a heartbeat to the active controller (default 9000, 9 seconds); when it runs out, the controller fences the broker and moves leadership away from it.

## Further reading

- [AutoMQ v1.7.4 source on GitHub](https://github.com/AutoMQ/automq/blob/1.7.4/s3stream/src/main/java/com/automq/stream/s3/S3Stream.java)

## Troubleshooting

- [TimeoutException in Kafka producers: causes and fixes](https://monedula.dev/kafka/troubleshooting/producer-timeout-exception/)
- [NOT_LEADER_OR_FOLLOWER in Kafka: causes and fixes](https://monedula.dev/kafka/troubleshooting/not-leader-or-follower/)
