Scenario 12.1.3 · Nisshi: two brokers, one partition
Nisshi diskless Kafka: two brokers write one partition
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 this scenario in the playgroundTwo 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: step 1, Two brokers send a request for orders-0 in the same millisecondbroker-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: step 2, broker-1 creates watermark.json; broker-2's create fails with 412broker-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: step 3, broker-2 reads version 1 and takes offset 1Both 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: step 4, Both batches are written; p2 is acked one round laterbroker-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: step 5, broker-1's copy is stale: its write gets 412, then offset 3Offsets 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: step 6, Offsets 0 to 3, no gap, read in orderWhat 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
- 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: step 1, Two brokers send a request for orders-0 in the same millisecond
- 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: step 2, broker-1 creates watermark.json; broker-2's create fails with 412
- 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: step 3, broker-2 reads version 1 and takes offset 1
- 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: step 4, Both batches are written; p2 is acked one round later
- 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: step 5, broker-1's copy is stale: its write gets 412, then offset 3
- 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: step 6, Offsets 0 to 3, no gap, read in order
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
-
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
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.3" title="Kafka Simulator: Nisshi: two brokers, one partition" 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-two-brokers-one-partition/">Nisshi diskless Kafka: two brokers write one partition</a></p> Further reading
Nisshi v0.8.2 source on GitHub
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 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: 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