Scrivio Interview library
DebuggingIntermediate6 min read · updated 13 November 2026

A service reads the output topic of an exactly-once Kafka Streams app with isolation.level=read_committed. Its lag on partition 7 has grown for three hours while other partitions are fine, and a test consumer with read_uncommitted reads partition 7 normally.

The Streams app was killed and restarted in a hurry during an incident earlier that day. Explain what is blocking the consumer and how you would confirm and clear it.

The read_committed consumer is stuck behind a hanging transaction on partition 7: an open transaction that was never committed or aborted, which pins the last stable offset (LSO) so read_committed readers cannot pass it. We confirm it with kafka-transactions.sh describe-producers and find-hanging, and clear it with kafka-transactions.sh abort, which writes an abort marker and lets the LSO move forward. Then we alert on the gap between the high watermark and the LSO.

Why this question is asked

Transactions make exactly-once possible, but they also add a new way for a consumer to stop moving while nothing looks broken: the topic keeps growing, the producer is healthy, and one partition's read_committed lag climbs for hours. The clue in this question is that a read_uncommitted consumer reads the same partition normally. Interviewers ask it to see whether we understand how read_committed decides how far it may read and what happens when a transaction is left open. In this answer, we will recap the last stable offset, explain how a hurried restart can leave a transaction hanging, then confirm it with the transactions tool, clear it, and set up alerts so the next one is found in minutes, not hours.

1A Quick Recap: High Watermark and Last Stable Offset

Every partition has a high watermark, the offset up to which records are replicated to all in-sync replicas and can be read. A read_uncommitted consumer reads up to the high watermark, including records from transactions that are still open.

A read_committed consumer must not show records from a transaction that might still abort, so it reads only up to the last stable offset. The LSO is the first offset of the oldest transaction that is still open on that partition; if no transaction is open, the LSO equals the high watermark. Records after the LSO, even committed ones from other producers, wait until that oldest transaction finishes. So one open transaction blocks every read_committed reader of the partition behind it.

Partition 7 while the transaction hangs
OffsetsContentVisible to read_committed?
0 to 811,999committed recordsYes
812,000first record of producer 5021's open transactionNo: this is the LSO
812,001 to 9,400,000later records, mostly committedNo, held behind the LSO
9,400,000high watermarkread_uncommitted reads to here
The numbers are an example; the shape is what matters.

2How a Transaction Ends Up Hanging

Normally an open transaction cannot block for long. If its producer dies, the transaction coordinator aborts it after transaction.timeout.ms (Kafka Streams sets this to 10 seconds under exactly-once; plain producers default to 60 seconds), or sooner when a new instance with the same transactional id fences the old one. The coordinator then writes abort markers to every partition it knows the transaction touched, and the LSO moves on.

A hanging transaction is one the coordinator no longer tracks. The classic path is a race during a hurried kill and restart: a produce request from the old producer is delayed in the network, the coordinator aborts the transaction and writes its markers, and then the late request lands on partition 7 and starts what the partition sees as a new open transaction. The coordinator believes that transaction is finished, so it never writes another marker, and no timeout will ever fire for it. The partition waits forever. KIP-890 added broker-side checks that reject such late writes; parts of it arrived in the 3.x line and the rest with transaction protocol version 2 in Kafka 4.0, so keeping brokers and clients current makes this much rarer. Check what your versions include.

3Confirming the Hanging Transaction

We first compare the two offsets for partition 7. The Admin client can list the latest offset under each isolation level, which gives the high watermark and the LSO directly.

Java
var p7 = new TopicPartition("balance-updates", 7);
long hw = admin.listOffsets(Map.of(p7, OffsetSpec.latest()),
new ListOffsetsOptions(IsolationLevel.READ_UNCOMMITTED)).partitionResult(p7).get().offset(); // 9400000
long lso = admin.listOffsets(Map.of(p7, OffsetSpec.latest()),
new ListOffsetsOptions(IsolationLevel.READ_COMMITTED)).partitionResult(p7).get().offset(); // 812000
// the LSO has not moved for three hours while hw keeps growing
$ kafka-transactions.sh --bootstrap-server b1:9092 describe-producers --topic balance-updates --partition 7
# ProducerId 5021 ... CurrentTransactionStartOffset 812000 (open for about 3 hours)
$ kafka-transactions.sh --bootstrap-server b1:9092 find-hanging --broker-id 3
# lists 5021 on balance-updates-7 as a hanging transaction

describe-producers asks the partition leader for the producers it has state for and shows any open transaction with its start offset. An open transaction whose start offset equals our stuck LSO and whose age is far beyond any transaction timeout is the culprit. find-hanging, run against the leader's broker id, checks each open transaction against the coordinator and reports the ones the coordinator does not know about or has already completed. If both point at the same producer and offset, we have confirmed it.

4Clearing It

We clear it by aborting the transaction from outside, telling the tool which partition and start offset it begins at.

Shell
$ kafka-transactions.sh --bootstrap-server b1:9092 abort \
--topic balance-updates --partition 7 --start-offset 812000
# the leader writes an abort marker for producer 5021 on partition 7
# LSO moves forward -> read_committed lag on partition 7 starts falling
Step throughDiagnosing a stuck read_committed partition
  1. read_committed lag grows on one partition
  2. read_uncommitted reads it fine?rules out a broken partition
    YesLSO is pinnedNocheck broker and consumer health
  3. Compare LSO and high watermarklistOffsets under both isolation levels
  4. describe-producers on the partitionopen transaction at the LSO, hours old
  5. find-hanging confirms it?
    Yesabort with start offsetNoinvestigate the live producer
  6. Watch lag falland the downstream catch-up

6 steps in order. Play them, or step through them one at a time.

The abort writes a marker directly to the partition, which requires cluster-level permission (the ClusterAction operation), so in most companies a platform engineer runs it. Notice that the hanging records are aborted, not committed. That is correct: the producer that wrote them is long gone and the restarted Streams app has already reprocessed its input, so committing them would publish duplicates. After the abort, the stuck consumer reads three hours of backlog, so we watch its catch-up and the systems it feeds.

5Preventing a Repeat

This went unnoticed for three hours because nothing failed; one number just stopped moving. We can alert on the gap between high watermark and LSO per partition, either from the broker's log metrics where available or with a small job that runs the listOffsets comparison above every minute for the critical topics. A simpler proxy is read_committed consumer lag that keeps rising on one partition while the produce rate is normal. Either should page within minutes. We also keep brokers and clients on versions with the KIP-890 fixes, and treat hurried kill -9 restarts of transactional apps as something to avoid: a clean shutdown lets the producer abort its own transaction.

6Follow-up questions

Why did only partition 7 stall?

The late write from the old producer landed only on partition 7, so only that partition has an open transaction the coordinator does not track. Other partitions received their abort markers normally and their LSO kept pace with the high watermark.

Would restarting the stuck consumer help?

No. The consumer is behaving correctly; it is the partition's LSO that is stuck. Restarting it or resetting its offsets changes nothing until the transaction is aborted.

Is it safe to abort a transaction by hand?

It is safe when we have confirmed it is hanging, meaning no live producer owns it. Aborting a transaction that a live producer is still working on would make that producer fail its commit, so we check describe-producers and find-hanging first and keep a record of what we aborted.

7Conclusion

In this answer, we saw that a read_committed consumer reads only up to the last stable offset, and that a transaction the coordinator no longer tracks pins the LSO forever, while read_uncommitted readers carry on to the high watermark. A hurried restart can leave such a hanging transaction through a late write. We confirmed it with describe-producers and find-hanging, cleared it with kafka-transactions.sh abort, and added alerts on the gap between high watermark and LSO.

What to say in the interviewAbout 80 seconds aloud

Open with

Because read_uncommitted reads partition 7 normally, the partition itself is fine; what is stuck is the last stable offset. A read_committed consumer can only read up to the first offset of the oldest open transaction on the partition, and if a transaction there is never committed or aborted, the LSO stops and every read_committed reader stalls behind it.

Then, if they want more

Normally the coordinator aborts a transaction after its timeout, but a hurried kill can leave a hanging transaction, for example a delayed produce request that lands after the coordinator already wrote its abort markers, so the partition sees an open transaction the coordinator no longer tracks.

To confirm, I would compare the LSO and high watermark for partition 7, then run kafka-transactions.sh describe-producers on that topic and partition to see the open transaction and its start offset, and find-hanging against the leader broker.

To clear it I would run kafka-transactions.sh abort with the topic, partition and start offset; that needs cluster permission, writes an abort marker, and the LSO moves forward, after which the consumer catches up.

Going forward I would alert on the gap between high watermark and LSO per partition, or on read_committed lag that grows while produce rates are normal, and keep brokers and clients on versions with the KIP-890 fixes.

About this answer

Last updated
13 November 2026
Versions it names
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 "The Streams app was killed and restarted in a hurry during an incident earlier that day....": https://scrivio-interview-library.netlify.app/spring-boot/kafka-streams-connect/76b0c070dd/