Quick revision
The short answer
With processing.guarantee=exactly_once_v2, each stream thread wraps its output records, its state store changelog writes and the input offsets it consumed into one Kafka transaction, so after a crash either all three are visible or none are. Downstream consumers must read with isolation.level=read_committed to benefit, the brokers must be 2.5 or later with safely replicated internal topics, and the app commits every 100 ms by default. Anything the app does outside Kafka, such as HTTP calls or database writes, is not covered.
What to remember
In this answer, we saw that exactly_once_v2 commits output records, changelog writes and consumed input offsets in one transaction per stream thread, so a crash leaves all of them or none. Downstream consumers need read_committed, brokers must be 2.5 or later with replicated internal topics, and the old exactly_once values are gone in Kafka 4.0. The commit interval drops to 100 ms, adding some overhead and latency, and side effects outside Kafka are still at-least-once.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
With processing.guarantee=exactly_once_v2, each stream thread wraps its output records, its state store changelog writes and the input offsets it consumed into one Kafka transaction, so after a crash either all three are visible or none are. Downstream consumers must read with isolation.level=read_committed to benefit, the brokers must be 2.5 or later with safely replicated internal topics, and the app commits every 100 ms by default. Anything the app does outside Kafka, such as HTTP calls or database writes, is not covered.
Why this question is asked
A balance service is the textbook case for exactly-once: if a transfer is applied twice after a crash, a customer's balance is simply wrong. Setting one property sounds too easy, and interviewers ask this question to see whether we know what that property actually promises, what it asks of the rest of the system, and where it stops. In this answer, we will recap what can go wrong without it, follow one commit to see what is made atomic, then cover what downstream consumers and brokers must do, how the app's behaviour changes, and which effects remain outside the guarantee.
1A Quick Recap: What Goes Wrong Without It
Under the default at_least_once guarantee, a Kafka Streams app processes a batch of input records, writes output records and state changes, and every 30 seconds commits the input offsets, the positions it has finished reading. Each of those is a separate action. If the instance crashes after it wrote balance-updates and changed the store but before it committed the offsets, the task restarts from the last committed offsets and processes the same transfers again. The store is restored from its changelog, a compacted topic that records every store write, which already contains the first application, so the balance moves twice and a second balance-update is published.
Exactly-once removes that window by making the three actions one.
2What Is Committed Together
With exactly_once_v2, each stream thread owns one transactional producer. A transaction in Kafka is a group of writes, possibly to many partitions, that become visible together or not at all. Between commits the thread sends its output records to balance-updates, its store writes to the changelog topic, and then adds the input offsets to the same transaction with sendOffsetsToTransaction. When it commits, the transaction coordinator, a broker-side component, writes commit markers into every partition involved, including the __consumer_offsets partition that holds the offsets.
6 messages in order. Play them, or step through them one at a time.
Output, changelog and input offsets become visible together.
If the instance dies before the commit, the coordinator aborts the transaction when the producer is fenced by a new instance or when the transaction times out. The aborted output and changelog records stay in the log but are marked aborted, the offsets never move, and the new owner of the task reprocesses the same transfers against a store restored only from committed changelog records. So each transfer affects the committed balance exactly once.
3Configuring It
The property itself is one line, but the internal topics need replication settings that make the guarantee worth having.
The older values exactly_once and exactly_once_beta were deprecated in Kafka 3.0 and removed in 4.0, so exactly_once_v2 is the only exactly-once setting today. It needs brokers at version 2.5 or later, which any current cluster is. Replication factor 3 with min.insync.replicas 2 is the usual production choice for the changelog and repartition topics, because a transaction is only as durable as the partitions it writes to.
4What Downstream Consumers Must Do
Here is the part that surprises teams. Aborted records are still physically in the topic. A consumer reading with the Java client's default, isolation.level=read_uncommitted, reads them anyway, so a reporting service can see a balance-update that was later rolled back and then see the reprocessed one too. Only consumers set to read_committed skip aborted records and stop at the last stable offset, the point before the oldest transaction still open.
Kafka Streams sets read_committed on its own consumers when exactly-once is on, so a chain of Streams apps is safe. Every other consumer of balance-updates must be configured explicitly. A good habit is to put that requirement in the topic's documentation, because the producer side cannot enforce it.
| Reader | Sees aborted records? | Reads up to |
|---|---|---|
| Consumer with read_uncommitted (default) | Yes | High watermark |
| Consumer with read_committed | No | Last stable offset |
| Kafka Streams with exactly_once_v2 | No (set automatically) | Last stable offset |
5How the App's Behaviour Changes
Turning exactly-once on changes the commit interval. Under at_least_once, commit.interval.ms defaults to 30 seconds; under exactly-once it defaults to 100 ms. The reason is that read_committed consumers see results only after a commit, so a 30-second interval would make every balance-update at least 30 seconds late. Even at 100 ms, end-to-end latency now includes the time until the next commit.
Each commit also costs extra round trips to the coordinator and markers in every partition written, so throughput is somewhat lower than at_least_once, more so with very short commit intervals. Raising commit.interval.ms improves throughput and increases latency; it is a real trade-off we tune per app. Finally, recovery after a crash can take longer, because state that may contain uncommitted writes has to be rebuilt from the changelog, which the FAQ below explains.
6What It Does Not Cover
Exactly-once is a property of reads and writes that go through Kafka. If a processor calls a fraud-check HTTP service, writes to a database, or sends an email, that call happens during processing, and when the transaction aborts and the records are processed again, the call happens again. Likewise, data read from another system is not part of the transaction. For those effects we still need idempotent designs, such as an idempotency key, or we move the effect behind a topic consumed by a service built for it.
7Follow-up questions
Why can a crash under exactly-once force a full restore of local state?
The local RocksDB store is written as records are processed, before the transaction commits. After an unclean crash, the store on disk may contain writes from a transaction that was then aborted, and Streams cannot tell which ones. So it does not trust the local copy: it wipes the task's store and rebuilds it from the committed changelog records, which for a large store can take many minutes. Standby replicas shorten this, and newer Kafka versions are adding transactional state stores (KIP-892) to avoid the wipe; check your version.
Does exactly-once make the producer idempotent too?
Yes. A transactional producer is always idempotent, so retries after a network error do not create duplicates within a partition. Transactions add atomicity across partitions on top of that.
Is exactly-once worth it for a counter that feeds a dashboard?
Often not. If an occasional double count is acceptable, at_least_once gives lower latency and overhead. For balances, where a duplicate is a wrong number shown to a customer, it is worth the cost.
8Conclusion
In this answer, we saw that exactly_once_v2 commits output records, changelog writes and consumed input offsets in one transaction per stream thread, so a crash leaves all of them or none. Downstream consumers need read_committed, brokers must be 2.5 or later with replicated internal topics, and the old exactly_once values are gone in Kafka 4.0. The commit interval drops to 100 ms, adding some overhead and latency, and side effects outside Kafka are still at-least-once.
Open with
With exactly_once_v2 each stream thread uses a transactional producer. Between commits it writes the output records to balance-updates, the store changes to the changelog topic, and then adds the input offsets it consumed to the same transaction, so they all commit together.
Then, if they want more
If the instance crashes mid-batch, the transaction aborts, the offsets do not move, and the next owner reprocesses the transfers against state restored only from committed changelog records, so each transfer counts once. Two things it requires: brokers 2.5 or later, with internal topics at replication factor 3 and min.insync.replicas 2 in production, and downstream consumers set to isolation.level=read_committed.
The Java consumer defaults to read_uncommitted, which would show records from aborted transactions; Streams sets read_committed on its own consumers. The older exactly_once and exactly_once_beta values were removed in Kafka 4.0.
Behaviour changes too: commit.interval.ms defaults to 100 milliseconds instead of 30 seconds, because read_committed readers only see results after a commit, so there is extra overhead per commit and latency includes that interval. And it stops at Kafka's boundary: an HTTP call or database write inside a processor can still run more than once.
About this answer
- Last updated
- 13 November 2026
- Versions it names
- Kafka 3.0, Kafka 4.0
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- Apache Kafka documentation
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "Explain what this guarantees for input offsets, the store's changelog and the output...": https://scrivio-interview-library.netlify.app/spring-boot/kafka-streams-connect/7494573f1e/