Scenario 09.1.2 · AutoMQ: a broker crashes and its WAL is replayed
AutoMQ diskless Kafka: a broker crash and WAL failover
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 this scenario in the playgroundbroker-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: step 1, broker-1 leads two partitions, its WAL buffer is fillingBroker-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: step 2, Broker-1 crashes: acks=1 records in its buffer are lostFor 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: step 3, For 9 s the partitions keep their dead leader: produce times outThe 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: step 4, The controller fences broker-1; its partitions have no leaderAnother 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: step 5, Another broker replays broker-1's WAL into an SSOThe 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: step 6, The partitions reopen elsewhere with epoch 1; retries are ackedThe 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: step 7, The consumer reads on: no acks=all record lostWhat 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
- 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: step 1, broker-1 leads two partitions, its WAL buffer is filling
- 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: step 2, Broker-1 crashes: acks=1 records in its buffer are lost
- 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: step 3, For 9 s the partitions keep their dead leader: produce times out
- 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: step 4, The controller fences broker-1; its partitions have no leader
- 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: step 5, Another broker replays broker-1's WAL into an SSO
- 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: step 6, The partitions reopen elsewhere with epoch 1; retries are acked
- 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: step 7, The consumer reads on: no acks=all record lost
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
-
acksHow 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 -
retriesHow 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.How long the producer waits before retrying a failed send, so it does not hammer a broker that is still recovering.backoff. ms -
delivery.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.timeout. ms -
broker.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.session. timeout. ms
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=09.1.2" title="Kafka Simulator: AutoMQ: a broker crashes and its WAL is replayed" width="100%" height="520" style="border:1px solid #d0d0d0;border-radius:8px" loading="lazy" referrerpolicy="no-referrer-when-downgrade"></iframe>
<p><a href="https://monedula.dev/kafka-simulator/scenarios/automq-broker-crash-wal-failover/">AutoMQ diskless Kafka: a broker crash and WAL failover</a></p> Further reading
AutoMQ v1.7.4 source on GitHub
Troubleshooting
- TimeoutException in Kafka producers: causes and fixes
- NOT_LEADER_OR_FOLLOWER in Kafka: causes and fixes
More in Diskless
- Diskless Kafka topics (KIP-1163): the write path
- Diskless vs classic Kafka: cross-AZ replication traffic
- Diskless Kafka produce latency: the price of object storage
- Diskless Kafka (KIP-1163): when object storage goes down
- Aiven Inkless diskless Kafka: the write path
- Aiven Inkless: what a PostgreSQL outage does to Kafka
- Aiven Inkless: what losing a Kafka broker costs
- Aiven Inkless: a slow S3 bucket fails Kafka produce
- KafScale diskless Kafka: etcd lease, S3 segment, ack
- KafScale 2.1 diskless Kafka: a lease owner crashes
- KafScale 2.1 diskless Kafka: when etcd goes down
- KafScale 2.1 diskless Kafka: when S3 goes down
- KafScale 2.1 proxy: etcd down past the 60 s cache TTL
- KafScale 2.1: a Kafka producer timeout that still wrote
- KafScale 2.1 diskless Kafka: lease handover, no overwrite
- KafScale 2.1 diskless Kafka: a paused broker comes back
- AutoMQ diskless Kafka: one S3 WAL per broker, then ack
- AutoMQ diskless Kafka: moving a partition, no copying
- AutoMQ diskless Kafka: zone router, no cross-zone data
- AutoMQ diskless Kafka: when S3 goes down
- WarpStream diskless Kafka: the write path through Agents
- WarpStream Kafka: a leader per client, a cache per zone
- WarpStream Kafka: an Agent dies mid-commit
- WarpStream Kafka: the control plane goes down
- WarpStream Kafka Ripcord: produce without the control plane
- WarpStream Kafka lightning topics: ack before the commit
- WarpStream Kafka transactions in the control plane
- Redpanda Kafka write path: the offset comes after S3
- Redpanda Kafka leader crash: a Raft election, no replay
- Redpanda Kafka S3 outage: uploads time out, Raft holds
- Redpanda Kafka L0 to L1: the LRO and who serves a read
- Redpanda Kafka transactions: exactly-once on Cloud Topics
- Nisshi diskless Kafka: watermark.json, then the batch
- Nisshi diskless Kafka on PostgreSQL: a row lock per write
- Nisshi diskless Kafka: two brokers write one partition
- Nisshi diskless Kafka: reading through another broker
- Nisshi diskless Kafka: a broker dies mid-write
- Nisshi diskless Kafka: when PostgreSQL goes down
- Nisshi diskless Kafka: what 0.8.2 refuses
- Ursa for Kafka write path: Oxia assigns the offset
- Ursa for Kafka zones: the zonal owner and the zone cache
- Ursa for Kafka compaction: from WAL objects to Parquet
- Ursa for Kafka broker failure: a kill and a silent broker
- Ursa for Kafka: diskless and disk topics, side by side