---
title: "Nisshi diskless Kafka: two brokers write one partition"
description: "On Nisshi's S3 engine two brokers write one partition at once: the conditional write of watermark.json orders them; the loser gets 412 and writes again."
url: https://monedula.dev/kafka-simulator/scenarios/nisshi-two-brokers-one-partition/
---

# Nisshi diskless Kafka: two brokers write one partition

Scenario 12.1.3 · Nisshi: two brokers, one partition. Diskless · Advanced · about 3 min · Apache Kafka 4.4 · Nisshi 0.8.2.

Nisshi 0.8.2 on S3 · two brokers write one partition at once: the conditional write of watermark.json picks the order, the loser gets 412, reads the document and writes again.

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

## What you start with

On Nisshi's S3 engine no broker leads a partition: any broker can write any partition. What orders two writers is the partition's watermark.json, written with a version check. The broker that loses the race gets 412 (precondition failed), reads the document again and writes again at once. p1 talks to broker-1 and p2 to broker-2; both are plain producers (acks=all) writing orders-0, and consumer group g1 reads through broker-1.

## Step by step

1. **Two brokers send a request for orders-0 in the same millisecond** (t+0.150s): p1 on broker-1 and p2 on broker-2 send a record for orders-0 at 100, and both requests leave at 150. Neither broker holds a copy of orders-0's watermark.json yet. [Open at this step](https://monedula.dev/kafka-simulator/playground/?scenario=12.1.3&t=0)
2. **broker-1 creates watermark.json; broker-2's create fails with 412** (t+0.200s): Both brokers try to create the document. broker-1's lands first: version 1, offset 0 is p1's, and its PUT starts. broker-2's create fails because the document now exists (PutMode::Create in the code), so broker-2 has taken nothing yet. [Open at this step](https://monedula.dev/kafka-simulator/playground/?scenario=12.1.3&t=1)
3. **broker-2 reads version 1 and takes offset 1** (t+0.300s): broker-2 reads the document (version 1, high watermark 1) at 250 and writes again against version 1 at 300: version 2, offset 1 is p2's. [Open at this step](https://monedula.dev/kafka-simulator/playground/?scenario=12.1.3&t=2)
4. **Both batches are written; p2 is acked one round later** (t+0.601s): broker-1's PUT ends at 500 and p1 is acked at 501; broker-2's ends at 600 and p2 is acked at 601. The lost race cost p2 one read and one write, 100 ms. Offsets 0 and 1 follow the order of the watermark writes. [Open at this step](https://monedula.dev/kafka-simulator/playground/?scenario=12.1.3&t=3)
5. **broker-1's copy is stale: its write gets 412, then offset 3** (t+1.100s): Both send again at 900. broker-2 holds version 2, the current one, and writes version 3 (offset 2) at 1000. broker-1 still holds version 1, so its write fails with 412; it reads version 3 at 1050 and writes version 4 at 1100: offset 3. [Open at this step](https://monedula.dev/kafka-simulator/playground/?scenario=12.1.3&t=4)
6. **Offsets 0 to 3, no gap, read in order** (t+1.800s): Both batches are written (1300, 1400) and acked (1301, 1401). c1 reads through broker-1: offset 0 at 600, offset 1 at 1200, and offsets 2 and 3 at 1800. [Open at this step](https://monedula.dev/kafka-simulator/playground/?scenario=12.1.3&t=5)

## The takeaway

Every write to orders-0 went through one document, watermark.json, written with a version check. When two brokers raced, one won, and the other read the new version and wrote again, so the offsets stayed contiguous (0 to 3) in the order of the watermark writes and the loser was acked one round, 100 ms here, later. A broker writing after another broker's write always pays that round, since its copy is stale; the code retries with no cap and no backoff. Simulator choices: the pinned brokers, the 50 ms conditional write and read, the 300 ms PUT, and the response 1 ms after the PUT.

## 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/)

## Further reading

- [Nisshi v0.8.2 source on GitHub](https://github.com/nisshi-io/solace-nisshi/blob/v0.8.2/nisshi-storage-dynostore/src/dynostore.rs#L3018-L3444)
