Skip to content

Conversation

rreddy-22
Copy link
Contributor

@rreddy-22 rreddy-22 commented Sep 29, 2025

Cherry-pick changes (#20534) to 4.0

Conflicts:
-> storage/src/main/java/org/apache/kafka/storage/internals/log/UnifiedLog.java - kept the file the same, and the rest of the code is in UnifiedLog.scala in 4.0 so added it there
-> core/src/test/scala/unit/kafka/log/UnifiedLogTest.scala - just added the required test and kept everything else the same

Reviewers: Justine Olshan [email protected], Chia-Ping Tsai [email protected]

…t unexpected fatal error (apache#20534)

We are seeing cases where a Kafka Streams (KS) thread stalls for ~20
seconds. During this stall, the broker correctly aborts the open
transaction (triggered by the 10-second transaction timeout).   However,
when the KS thread resumes, instead of receiving the expected
InvalidProducerEpochException (which we already handle gracefully as
part of transaction abort), the client is instead hit with an
InvalidTxnStateException. KS currently treats this as a fatal error,
causing the application to fail.

To fix this, we've added an epoch check before the verification check to
send the recoverable  InvalidProducerEpochException instead of the fatal
InvalidTxnStateException. This helps safeguard both tv1 and tv2 clients

Reviewers: Justine Olshan <[email protected]>
@github-actions github-actions bot added triage PRs from the community streams core Kafka Broker producer consumer tools connect performance kraft mirror-maker-2 dependencies Pull requests that update a dependency file storage Pull requests that target the storage module tiered-storage Related to the Tiered Storage feature KIP-932 Queues for Kafka build Gradle build or GitHub Actions docker Official Docker image generator RPC and Record code generator transactions Transactions and EOS clients group-coordinator labels Sep 29, 2025
@rreddy-22 rreddy-22 changed the base branch from trunk to 4.0 September 29, 2025 02:45
@rreddy-22 rreddy-22 marked this pull request as ready for review September 29, 2025 02:45
@chia7712
Copy link
Member

@rreddy-22 Could you please open PR for 4.2 as well? I try to cherry-pick it but there are some conflicts :(

@omkreddy
Copy link
Contributor

@rreddy-22 Could you please open PR for 4.2 as well? I try to cherry-pick it but there are some conflicts :(

4.1

@rreddy-22
Copy link
Contributor Author

rreddy-22 commented Sep 30, 2025

@rreddy-22 Could you please open PR for 4.2 as well? I try to cherry-pick it but there are some conflicts :(

Yes, I was going in order so will raise that PR next! Haha yeah there are quite a few conflicts #20618

@github-actions github-actions bot removed the triage PRs from the community label Oct 1, 2025
Copy link
Member

@chia7712 chia7712 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rreddy-22 Thanks for the backport. The formatting looks mostly good, but a few of the changes seems a little strange. Could you double-check them?

currentTxnStartOffset: Option[Long],
coordinatorEpoch: Option[Int]
): Unit = {
producerId: Long,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mind reverting this? I think it was accidentally done by the auto-formatter. 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah ugh it's the auto formatter

@jolshan jolshan removed streams core Kafka Broker producer consumer tools connect performance kraft mirror-maker-2 dependencies Pull requests that update a dependency file storage Pull requests that target the storage module tiered-storage Related to the Tiered Storage feature KIP-932 Queues for Kafka build Gradle build or GitHub Actions docker Official Docker image generator RPC and Record code generator clients group-coordinator labels Oct 2, 2025
@jolshan
Copy link
Member

jolshan commented Oct 2, 2025

Can we get the change isolated without the formatting changes?

@chia7712 chia7712 merged commit 4b0ba42 into apache:4.0 Oct 6, 2025
7 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-approved transactions Transactions and EOS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants