Monedula

Scenario 13.1.4 · Ursa for Kafka: a broker dies, and a broker goes silent

Ursa for Kafka broker failure: a kill and a silent broker

Diskless · Advanced · about 5 min · Apache Kafka 4.4 · StreamNative Ursa for Kafka

StreamNative Ursa for Kafka · a killed broker's clients move at once: its buffer is lost, the object it was uploading is an orphan, the object whose commit it sent still commits with its acks lost, and Oxia drops the idempotent retry; a paused broker keeps its partitions until 5 s of missed heartbeats.

Run this scenario in the playground

broker-1 dies: the buffer is lost, the object still uploading is an orphan. t+1.350s

broker-1 is hard-killed. Its open buffer wal-0003 is gone with its 2 records, and wal-0002, still uploading, is an orphan: it will never commit. Those 4 records get REQUEST_TIMED_OUT now (the sources name no code, a simulator choice), and both producers will retry. wal-0001 was already sent to Oxia, so its ack is lost: it still commits, but no producer hears back. The kill closes the connections, so the clients look up a new owner at once. az-a has no alive broker now, so the simulator hashes its clients over every alive broker: orders-2 goes to broker-2.

Open at this step: step 2, broker-1 dies: the buffer is lost, the object still uploading is an orphan

What you start with

In Ursa for Kafka a broker holds nothing acked: a record is acked only after its WAL object is uploaded and Oxia commits it. Two producers in az-a, p-idem (idempotent) and p-plain (idempotence off, retry.backoff.ms 1000), both with acks set to all and client.id: zone_id=az-a, write orders through broker-1, their zonal owner. Consumer group g1 reads in az-b through broker-2. broker-1 is hard-killed while it holds an open buffer, an object still uploading and an object whose Oxia commit it has sent. Later broker-2, which holds only diskless partitions, is paused: alive, but silent. The timings are slowed so each phase gets its own frame (a simulator choice).

Step by step

  1. broker-1 holds a buffer, an object still uploading and one whose commit was sent t+1.300s p-idem and p-plain (client.id: zone_id=az-a) sent one record each at 100, 700 and 1250, all to orders-2, and broker-1, their zonal owner, buffered each pair into a WAL object. wal-0001 (k1, k3) was uploaded from 650 to 1250 and its commit request sent to Oxia at 1250; the commit lands at 1450. wal-0002 (k4, k6) closed at 1250 and is still uploading until 1850. wal-0003 (k12, k20) is the open buffer, since 1300. None of the six records is committed or acked yet: orders-2 has no offsets. Open at this step: step 1, broker-1 holds a buffer, an object still uploading and one whose commit was sent
  2. broker-1 dies: the buffer is lost, the object still uploading is an orphan t+1.350s broker-1 is hard-killed. Its open buffer wal-0003 is gone with its 2 records, and wal-0002, still uploading, is an orphan: it will never commit. Those 4 records get REQUEST_TIMED_OUT now (the sources name no code, a simulator choice), and both producers will retry. wal-0001 was already sent to Oxia, so its ack is lost: it still commits, but no producer hears back. The kill closes the connections, so the clients look up a new owner at once. az-a has no alive broker now, so the simulator hashes its clients over every alive broker: orders-2 goes to broker-2. Open at this step: step 2, broker-1 dies: the buffer is lost, the object still uploading is an orphan
  3. The sent commit lands, but its ack is lost: the producers retry t+1.450s Oxia commits wal-0001 after its broker is gone: k1 (p-idem) at orders-2 offset 0 and k3 (p-plain) at offset 1, and the offset index points them at the object. broker-1 is gone, so no ack reaches the producers: both get REQUEST_TIMED_OUT instead, although their records are now in the log. Each producer retries every record it was not acked for: p-idem after 400 ms, p-plain after its retry.backoff.ms of 1000. Open at this step: step 3, The sent commit lands, but its ack is lost: the producers retry
  4. Clients move to a new owner at once; Oxia dedupes the idempotent retry t+3.050s The retries went straight to broker-2, the new owner: p-idem's k4 and k12 at 1750 and k1 at 1850 into wal-0004, p-plain's from 2350 into the next object. broker-2 uploaded wal-0004 at 2250 and Oxia committed it now. Producer state lives in Oxia, keyed by partition and producer id, and the simulator checks sequences at the commit: k1's sequence 0 is already committed, so Oxia drops it and acks it as a duplicate; k4 and k12 (sequences 1 and 2) take offsets 2 and 3. p-idem's records are each in the log once. Open at this step: step 4, Clients move to a new owner at once; Oxia dedupes the idempotent retry
  5. The plain producer's retry is written twice t+3.650s wal-0005 holds p-plain's three retries, k20, k6 and k3, and Oxia commits them at offsets 4 to 6 with no sequence to check. k3 was already at offset 1, from the commit whose ack was lost, so it is now in the log twice: a producer without idempotence cannot tell a lost ack from a lost record. g1 (zone_id=az-b) has read offsets 0 to 3 through broker-2 and reads 4 to 6 next, from broker-2's memory. Open at this step: step 5, The plain producer's retry is written twice
  6. The next compaction run removes the orphan t+4.150s The orphan armed the compaction service at the kill, so its run started 2 s later, at 3350, and lands now: one Oxia commit points offsets 0 to 3 of orders-2 at the Parquet file pq-0001, wal-0001 and wal-0004 are deleted, and the orphan wal-0002 is removed without ever having been committed. wal-0005 committed during the run, so the next run takes it (at 6950). broker-1 stays dead: the az-a producers keep writing through broker-2. Open at this step: step 6, The next compaction run removes the orphan
  7. broker-2 is paused: requests to it wait t+5.400s p-idem's k24 and p-plain's k25, sent at 4800, went into broker-2's buffer wal-0006 at 4850. broker-2 is paused at 5000 (SIGSTOP or a long GC pause): alive, but it answers nothing and sends no heartbeats. Its buffer should have closed at 5350; it stays open and frozen. k26 and k28, sent at 5300, still go to broker-2, the owner on record, and wait there: nothing fails yet, and the owners do not move. Open at this step: step 7, broker-2 is paused: requests to it wait
  8. After 5 s of missed heartbeats it is marked offline; its partitions move t+11.000s broker-2 sent no heartbeat for 5 s, so at 10000 it is marked offline and its partitions move. broker-1 is still dead, so the owner of orders-2 for both az-a and az-b is broker-3, the only broker both alive and online (the simulator's hash). The 4 records that waited, k24 and k25 in the frozen buffer and the requests k26 and k28, timed out with REQUEST_TIMED_OUT and are retried through broker-3: p-idem's at 10400 into wal-0007, p-plain's now into wal-0008. The frozen buffer is still on broker-2. The compaction service ran during the pause and wrote offsets 4 to 6 to pq-0002. Open at this step: step 8, After 5 s of missed heartbeats it is marked offline; its partitions move
  9. broker-2 resumes: its frozen buffer is dropped, it rejoins t+13.200s Oxia committed wal-0007 at 11700 (k24 and k26 at offsets 7 and 8, in sequence order) and wal-0008 at 12300 (k28 and k25 at 9 and 10), and g1 read both from broker-3's memory and committed offset 11. Now broker-2 resumes: its frozen buffer wal-0006 is dropped, never uploaded, since its records already timed out and were written through broker-3. broker-1 restarts at the same moment with an empty buffer. Both rejoin the hash, so az-a's clients go back to broker-1 and az-b's to broker-2. Every acked record is in orders-2 and g1 has read all 11 offsets, k3 twice. Open at this step: step 9, broker-2 resumes: its frozen buffer is dropped, it rejoins

The takeaway

broker-1 died holding three kinds of unfinished work, none of it acked. Its open buffer (k12, k20) was lost, and wal-0002 (k4, k6), still uploading, became an orphan that never commits: those four records got REQUEST_TIMED_OUT at the kill. wal-0001 (k1, k3) had been sent to Oxia for commit, so it committed at offsets 0 and 1 after the broker was gone, and its producers got timeouts instead of acks. The producers retried at once through broker-2: Oxia found p-idem's k1 already committed for its producer id and sequence and acked it as a duplicate, while p-plain's k3 carried no sequence and was written again at offset 6. The next compaction run removed the orphan. Then broker-2 was paused with k24 and k25 in its buffer: k26 and k28 waited for it, and nothing moved for 5 s. At the heartbeat loss its partitions moved to broker-3, the four waiting records timed out and were retried there, and the resume dropped the frozen buffer. g1 read all 11 records, every acked one among them. Ursa facts: a kill closes the connections, so clients re-resolve at once; a silent broker is noticed only after 5 s of missed heartbeats (the paper, 4.2.5); producer state lives in Oxia, so a retry through another broker is still caught; the compaction service cleans up orphan WAL objects. Simulator choices: REQUEST_TIMED_OUT for the lost requests and the lost acks (the sources name no code); the dedupe done at the Oxia commit; a zone with no alive broker hashed over every alive broker; the heartbeat counted from the pause; the frozen buffer dropped on resume, with no late commit; the pause refused while a broker holds any disk-topic replica, which is why this cluster has no disk topic; the 2 s compaction interval; the 400 ms retry backoff of p-idem (p-plain sets 1000 ms); and the 500 ms buffer close, 600 ms upload and 200 ms Oxia commit, slowed.

Configs in this scenario

  • retry.backoff.ms How long the producer waits before retrying a failed send, so it does not hammer a broker that is still recovering.
  • client.id On Ursa for Kafka a client asks for zone affinity by starting its client.id with zone_id= and its zone (zone_id=az-a, or zone_id=az-a,key1=value1 with other entries after it), and at least one broker must run in that zone.

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=13.1.4" title="Kafka Simulator: Ursa for Kafka: a broker dies, and a broker goes silent" 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/ursa-broker-dies/">Ursa for Kafka broker failure: a kill and a silent broker</a></p>

Further reading

VLDB paper (PDF)

Troubleshooting

More in Diskless

All scenarios