Unit 3 of 15 · about 4 hours · explain, derive

Producer acknowledgements, idempotent sequence state and transactional scope

Retried requests are certain and ambiguous outcomes are permanent: a timeout never says whether the write landed. Acknowledgements, sequence state and transactions are the three tools that make retries safe.

You'll be able to

  • Explain acks 0, 1 and all as durability versus latency choices gated by min.insync.replicas.
  • Explain the idempotent producer's per-partition sequence state and what breaks duplicate suppression.
  • Derive the atomic scope of a Kafka transaction: which partition writes and offsets commit together, and what stays outside it.

Covers

Producer acknowledgement choicesIdempotent producer sequence stateTransactional producer scope
1

Read

In this order, only the parts listed

0 of 3 done

  1. Delivery semantics and transactionsApache Kafka 4.3 - Design, Log, Rebalance and Transaction Protocols

    Message Delivery Semantics (at-most, at-least and exactly-once; idempotent producer with producer ID and sequence numbers); Using Transactions (offsets atomic with output; isolation.level=read_committed with enable.auto.commit=false and transactional.id)

  2. Server-side transaction defenseApache Kafka 4.3 - Design, Log, Rebalance and Transaction Protocols

    Overview: KIP-890 Transactions Server Side Defense, generally available since 4.0, with a producer epoch bump per transaction

    Read the Overview only. Skip Upgrade and Downgrade and Performance unless you run a multi-version setup.

  3. Atomic commit scope in stream processorsDDIA 2e - Chapters 11 to 13 Batch and Stream Processing

    Chapter 12, Atomic commit revisited (pp. 527 to 528): internal transactions in Dataflow, VoltDB and Kafka; overhead amortized over several input messages per transaction

2

Focus on

  • acks=0 never waits, acks=1 waits for the leader only, and acks=all waits for all current in-sync replicas, further gated by min.insync.replicas. Without that gate the ISR can shrink to the leader and all means the leader only.
  • Idempotence keys each retried batch by producer ID plus per-partition sequence numbers, so a batch the broker already wrote is acknowledged without a second append. It is per partition and holds only while the broker retains that producer's sequence state.
  • A transaction commits a set of partition writes plus consumer offsets atomically, readable under read_committed. Anything outside Kafka, such as a database write or an email, is not in that atomic scope.
  • Timeout ambiguity remains: a producer that times out cannot tell a lost request from a lost reply, so it must retry and let deduplication or the transaction decide.
Common mistakes · 3
  • Calling acks=all alone durable. Without min.insync.replicas the ISR can shrink to the leader, so all means the leader only.
  • Expecting transactions to cover external effects. The atomic scope ends at Kafka partition writes plus offsets.
  • Using kafka-console-producer.sh to test transactions. It cannot run transactions; use client code.
3

Try it yourself

Closed-book, before checking anything

Closed-book, write the acks and min.insync.replicas settings that lose an acknowledged write when the leader dies, and the settings that refuse the write instead, and state the read rule that hides aborted transactions.
4

Quiz yourself

Answer first, then mark it. Missed ones go to Review.

0 got · 0 missed

  1. 1.With acks=1, the leader acknowledges a write and dies before replicating it. Is the write lost?Answer

    Yes. Only the leader held it, so the acknowledgement promised nothing about replication.

  2. 2.With min.insync.replicas=2 and an ISR of just the leader, what does an acks=all write return?Answer

    An error refusing the write until the ISR recovers. The broker rejects instead of silently weakening durability.

  3. 3.A batch times out and the producer retries with the same sequence number. The broker already appended it. What happens?Answer

    The broker detects the duplicate sequence and acknowledges without appending again, so the retry is safe.

  4. 4.A transaction writes partitions A and B plus offsets, then aborts. What does a read_committed consumer see?Answer

    Nothing from that transaction: read_committed skips its aborted records. The consumer offsets written in the transaction never take effect either, so the input records are read and processed again.

You're done when

You can predict the fate of a write for each acks value under leader death, and draw the exact boundary of a transaction's atomic scope.

Only when you can do this without notes.

Leads to

Notes

Resources · 2 for this unit, 16 more in the section
  • DDIA 2e - Chapters 11 to 13 Batch and Stream ProcessingMartin Kleppmann and Chris Riccomini · primary

    Read batch processing, stream processing and the streaming-systems philosophy in order. For every guarantee, mark the source position, operator state, output effect and recovery boundary it actually covers.

  • Apache Kafka 4.3 - Design, Log, Rebalance and Transaction ProtocolsApache Kafka · required

    Read the 4.3 design page (replication and in-sync replicas, acknowledgements and min.insync.replicas, delivery semantics, idempotence and transactions, the consumer, log compaction), the log implementation page, and the consumer rebalance protocol and transaction protocol pages (https://kafka.apache.org/43/operations/). Kafka 4.0 removed ZooKeeper. Run experiments in the apache/kafka:4.3.1 image and compare each contract with your mini log.

Also in this section