Scenario 11.1.2 · Redpanda: the leader crashes, an election, nothing to replay
Redpanda Kafka leader crash: a Raft election, no replay
Redpanda v26.2.2 Cloud Topics · a hard kill loses the leader's L0 buffer and orphans an upload whose placeholder reached no follower; after the 1.5 s election timeout a follower leads with term + 1, with nothing to replay.
Run this scenario in the playgroundThe leader holds a buffer and a fresh placeholder no follower holds. t+2.850s
broker-2 leads orders-1, the partition p-idem writes. order-1 and order-2 are acked: their placeholders, offsets 0 and 1, are on all three brokers, and the consumer has read order-1 from broker-2's cache. order-3's L0 object l0-0003 finished uploading at 2800 ms and broker-2 appended its placeholder at offset 2, but it has not reached a follower yet (the simulator's next follower fetch is due at 3100 ms), so it is not acked and the high watermark stays 2. order-4 waits in broker-2's open L0 buffer (l0-0004), with no offset.
Open at this step: step 1, The leader holds a buffer and a fresh placeholder no follower holdsThe leader dies: its buffer is lost, the upload becomes an orphan. t+2.900s
broker-2 is hard-killed. Its L0 buffer is lost with order-4 in it. l0-0003 stays in S3, but its only placeholder was in broker-2's log, so no placeholder anywhere points at it: an orphan, which Redpanda's L0 garbage collection deletes after 12 h. Neither record had been acked. p-idem gets REQUEST_TIMED_OUT for both (the simulator's stand-in for the lost connection) and retries. orders-1 and orders-4, both led by broker-2, have no leader.
Open at this step: step 2, The leader dies: its buffer is lost, the upload becomes an orphanFor 1.5 s the partition has no leader: produce times out, retries are refused. t+4.100s
broker-1 and broker-3 wait for the Raft election timeout, election_timeout_ms, 1.5 s by default. Until it runs out orders-1 has no leader: p-idem's retries are refused with NOT_LEADER_OR_FOLLOWER (the simulator's choice: a real Java client holds its batches while the metadata shows no leader), and the consumer's polls get nothing. Two of the partition's three replicas are alive, a majority, so an election will come.
Open at this step: step 3, For 1.5 s the partition has no leader: produce times out, retries are refusedA follower is elected with term + 1: nothing to replay. t+4.400s
1.5 s after the kill, broker-1 becomes the leader of orders-1 with term + 1. Both followers held offsets 0 and 1 in the same term; broker-1 wins on its id (the simulator's pick). Nothing is replayed: broker-1's Raft log already holds the placeholders of every acked record, and the records themselves are in S3. broker-1 also takes over orders-4, which holds no record.
Open at this step: step 4, A follower is elected with term + 1: nothing to replayThe producer retries with the same sequence and goes on. t+5.900s
p-idem re-sends order-3 and order-4 to broker-1 with their original sequences 2 and 3. broker-1 buffers them in its own L0 object l0-0005, uploads it, and appends their placeholders at offsets 2 and 3; the sequence check at the placeholder append sees each once. The placeholders reach broker-3, and the leader and one follower are a majority of three, and p-idem is acked. Each record is in the log once. Meanwhile the consumer has read offset 1 from S3 (see the next frame).
Open at this step: step 5, The producer retries with the same sequence and goes onThe consumer reads on, first from S3: the new leader's cache is cold. t+7.000s
The consumer reads on from broker-1. Offset 1 is in l0-0002, which broker-2 uploaded: the new leader's batch cache is cold, so broker-1 reads that L0 object from S3 into its disk cache. Offsets 2 and 3 come from broker-1's own cache, filled when it appended their placeholders. g1 has committed all four records; the orphan l0-0003 stays in S3 until garbage collection.
Open at this step: step 6, The consumer reads on, first from S3: the new leader's cache is coldWhat you start with
broker-2 leads orders-1, the partition the idempotent producer p-idem (acks=all, az-a) writes four records to. As in the write path, each record waits in broker-2's L0 buffer, uploads to S3 in an L0 object, gets its offset when broker-2 appends a placeholder to the partition's Raft log, and is acked once a follower holds the placeholder too, a majority of three. broker-2 is hard-killed while it holds one record in its buffer and one upload whose placeholder it has appended but no follower holds yet. Consumer group g1 (az-a) reads orders. The buffer interval and the upload are slowed so each phase gets its own frame; the 1.5 s election timeout is Redpanda's default election_timeout_ms.
Step by step
- The leader holds a buffer and a fresh placeholder no follower holds t+2.850s broker-2 leads orders-1, the partition p-idem writes. order-1 and order-2 are acked: their placeholders, offsets 0 and 1, are on all three brokers, and the consumer has read order-1 from broker-2's cache. order-3's L0 object l0-0003 finished uploading at 2800 ms and broker-2 appended its placeholder at offset 2, but it has not reached a follower yet (the simulator's next follower fetch is due at 3100 ms), so it is not acked and the high watermark stays 2. order-4 waits in broker-2's open L0 buffer (l0-0004), with no offset. Open at this step: step 1, The leader holds a buffer and a fresh placeholder no follower holds
- The leader dies: its buffer is lost, the upload becomes an orphan t+2.900s broker-2 is hard-killed. Its L0 buffer is lost with order-4 in it. l0-0003 stays in S3, but its only placeholder was in broker-2's log, so no placeholder anywhere points at it: an orphan, which Redpanda's L0 garbage collection deletes after 12 h. Neither record had been acked. p-idem gets REQUEST_TIMED_OUT for both (the simulator's stand-in for the lost connection) and retries. orders-1 and orders-4, both led by broker-2, have no leader. Open at this step: step 2, The leader dies: its buffer is lost, the upload becomes an orphan
- For 1.5 s the partition has no leader: produce times out, retries are refused t+4.100s broker-1 and broker-3 wait for the Raft election timeout, election_timeout_ms, 1.5 s by default. Until it runs out orders-1 has no leader: p-idem's retries are refused with NOT_LEADER_OR_FOLLOWER (the simulator's choice: a real Java client holds its batches while the metadata shows no leader), and the consumer's polls get nothing. Two of the partition's three replicas are alive, a majority, so an election will come. Open at this step: step 3, For 1.5 s the partition has no leader: produce times out, retries are refused
- A follower is elected with term + 1: nothing to replay t+4.400s 1.5 s after the kill, broker-1 becomes the leader of orders-1 with term + 1. Both followers held offsets 0 and 1 in the same term; broker-1 wins on its id (the simulator's pick). Nothing is replayed: broker-1's Raft log already holds the placeholders of every acked record, and the records themselves are in S3. broker-1 also takes over orders-4, which holds no record. Open at this step: step 4, A follower is elected with term + 1: nothing to replay
- The producer retries with the same sequence and goes on t+5.900s p-idem re-sends order-3 and order-4 to broker-1 with their original sequences 2 and 3. broker-1 buffers them in its own L0 object l0-0005, uploads it, and appends their placeholders at offsets 2 and 3; the sequence check at the placeholder append sees each once. The placeholders reach broker-3, and the leader and one follower are a majority of three, and p-idem is acked. Each record is in the log once. Meanwhile the consumer has read offset 1 from S3 (see the next frame). Open at this step: step 5, The producer retries with the same sequence and goes on
- The consumer reads on, first from S3: the new leader's cache is cold t+7.000s The consumer reads on from broker-1. Offset 1 is in l0-0002, which broker-2 uploaded: the new leader's batch cache is cold, so broker-1 reads that L0 object from S3 into its disk cache. Offsets 2 and 3 come from broker-1's own cache, filled when it appended their placeholders. g1 has committed all four records; the orphan l0-0003 stays in S3 until garbage collection. Open at this step: step 6, The consumer reads on, first from S3: the new leader's cache is cold
The takeaway
When broker-2 died, two records were in flight and neither had been acked: order-4, lost with its L0 buffer, and order-3, whose L0 object had reached S3 but whose placeholder was in broker-2's log only. No placeholder points at that object any more, so it is an orphan, which Redpanda's L0 garbage collection deletes later, after 12 h. For 1.5 s, the Raft election timeout (election_timeout_ms), orders-1 had no leader and the retries were refused. Then a Raft election made broker-1, a follower holding offsets 0 and 1, the leader with term + 1. There was nothing to replay: the placeholders of every acked record were already in its log, and the records in S3. The idempotent producer re-sent order-3 and order-4 with their sequences 2 and 3; each was placed once, at offsets 2 and 3, and acked at the majority. Nothing acked was lost; what was lost had never been acked. The consumer read on: offset 1 from S3, because broker-1's batch cache was cold for an object broker-2 had uploaded, and offsets 2 and 3 from broker-1's own cache. Simulator choices: the requests a killed broker had not answered get REQUEST_TIMED_OUT at the kill, a stand-in for the lost connection; while the partition has no leader, retries are refused with NOT_LEADER_OR_FOLLOWER, where a real Java client holds its batches until the metadata shows a leader; the orphan stays drawn, since the 12 h garbage collection does not happen in a scene; the election takes exactly the 1.5 s timeout and picks the alive replica whose last entry has the newest term, then the most placeholders, ties by id, so broker-1 wins over broker-3, which held the same; and the buffer interval and the upload time are the slowed figures of the write path.
Configs in this scenario
-
acksOn a Redpanda Cloud Topics topic (redpanda.storage.mode=cloud) acks=1 and acks=all are answered at the same point, once the L0 object holding the batch is uploaded and a Raft majority holds its placeholder, because Cloud Topics replace the requested level with a quorum ack (acks=0 takes the same path). How acks works -
election_A Redpanda cluster property: the Raft election timeout, in milliseconds (default 1500).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=11.1.2" title="Kafka Simulator: Redpanda: the leader crashes, an election, nothing to replay" 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/redpanda-leader-crash-election/">Redpanda Kafka leader crash: a Raft election, no replay</a></p> Further reading
Redpanda v26.2.2 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: a broker crash and WAL failover
- 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 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