Monedula

Scenario 12.1.5 · Nisshi: a broker dies

Nisshi diskless Kafka: a broker dies mid-write

Diskless · Advanced · about 5 min · Apache Kafka 4.4 · Nisshi 0.8.2

Nisshi 0.8.2 on S3 · a hard kill ends each request where it is: offsets taken with no batch leave a gap, a batch stored without its ack is stored twice, and so is an idempotent batch stored before its sequence advance.

Run this scenario in the playground

broker-1 dies: a stored batch, an unrecorded sequence, a gap. t+1.000s

A hard kill at 1000 ends each request where it is. p-plain's PUT ended in this millisecond: the batch is stored, but the response, 1 ms behind (a simulator choice), never leaves. p-idem's batch is stored and its sequence never written. p-gap's PUT never ends: offset 0 of orders-2 is taken with no batch. All three producers get REQUEST_TIMED_OUT.

Open at this step: step 2, broker-1 dies: a stored batch, an unrecorded sequence, a gap

What you start with

Nisshi's brokers keep nothing that is not in S3, so a broker death moves no data and no group. But a request in flight ends where it is, and the S3 engine writes in steps: the offsets (watermark.json), the batch (its own object), and for an idempotent producer the sequence (meta.json), then the answer. broker-1 is hard-killed at 1000 with one request at each stage. Producers p-plain and p-gap (plain), p-idem (idempotent) and consumer group g1 all talk to broker-1.

Step by step

  1. broker-1 holds three requests at three stages t+0.999s Each producer writes its own partition through broker-1. p-idem's batch for orders-1 was written at 975, and its meta.json sequence advance is in flight. p-plain's PUT to orders-0 ends at 1000. p-gap's watermark write took offset 0 of orders-2 at 900, and its PUT runs until 1200. Open at this step: step 1, broker-1 holds three requests at three stages
  2. broker-1 dies: a stored batch, an unrecorded sequence, a gap t+1.000s A hard kill at 1000 ends each request where it is. p-plain's PUT ended in this millisecond: the batch is stored, but the response, 1 ms behind (a simulator choice), never leaves. p-idem's batch is stored and its sequence never written. p-gap's PUT never ends: offset 0 of orders-2 is taken with no batch. All three producers get REQUEST_TIMED_OUT. Open at this step: step 2, broker-1 dies: a stored batch, an unrecorded sequence, a gap
  3. c1 moves to broker-2 and reads on, skipping the gap t+1.200s c1 lost broker-1 too and moved at once to broker-2 (a hash over the alive brokers, the simulator's choice). The group's state is in S3, so nothing fails over: c1 reads offset 0 of orders-0 and orders-1, both stored, and moves past orders-2's offset 0, which holds no batch. Open at this step: step 3, c1 moves to broker-2 and reads on, skipping the gap
  4. The retries go through broker-3 t+1.550s The producers moved to broker-3 and retried after their 400 ms backoff. broker-3 held no copies, so its three creates fail with 412 at 1450; it reads the documents and takes offset 1 in each partition at 1550. Open at this step: step 4, The retries go through broker-3
  5. Both duplicates are stored t+1.901s p-plain's retry is a plain batch, so orders-0 holds its record at offsets 0 and 1. p-idem's retry passes the sequence check, since meta.json never recorded the first write, so orders-1 holds its record twice too. p-gap's record lands at offset 1 of orders-2. All are acked (1851, 1901). Open at this step: step 5, Both duplicates are stored
  6. c1 reads both duplicates; the gap stays empty t+6.600s broker-2's copies, read at 1200, expire at 6200, so c1 reads the retries at its 6600 poll: orders-0 and orders-1 give it each record twice, and orders-2 gives offset 1 only. Open at this step: step 6, c1 reads both duplicates; the gap stays empty

The takeaway

One kill, three outcomes, each from the order of the steps. p-gap's offsets were taken but its PUT never ended: offset 0 of orders-2 is a gap, which the fetch skips, as the code's comment above the produce path describes. p-plain's batch was stored in the millisecond of the kill without an ack, so its retry was stored a second time. p-idem's batch was stored before its meta.json advance, so its retry passed the sequence check and was stored again: the code calls this a known residual. Every client moved to another broker at once, and the group carried on with no coordinator to fail over. Simulator choices: REQUEST_TIMED_OUT for the lost connection, the hashes that sent c1 to broker-2 and the producers to broker-3, the 1 ms response, and the 400 ms retry backoff.

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=12.1.5" title="Kafka Simulator: Nisshi: a broker dies" 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/nisshi-broker-dies/">Nisshi diskless Kafka: a broker dies mid-write</a></p>

Further reading

Nisshi v0.8.2 source on GitHub

Troubleshooting

More in Diskless

All scenarios