Skip to content

Conversation

CalvinConfluent
Copy link
Contributor

When loading transaction metadata from a transaction log partition, if the partition contains a segment ending with an empty batch, "currOffset" update logic at will be skipped for the last batch. Since "currOffset" is not advanced to next offset of last batch properly, TransactionStateManager.loadTransactionMetadata method will be stuck in the "while" loop.

This change fixes the issue by updating "currOffset" after processing each batch, whether the batch is empty or not.

Reviewers: Justine Olshan [email protected], Jun Rao [email protected]

…saction metadata (apache#17688)

When loading transaction metadata from a transaction log partition, if the partition contains a segment ending with an empty batch, "currOffset" update logic at will be skipped for the last batch. Since "currOffset" is not advanced to next offset of last batch properly, TransactionStateManager.loadTransactionMetadata method will be stuck in the "while" loop.

This change fixes the issue by updating "currOffset" after processing each batch, whether the batch is empty or not.

Reviewers: Justine Olshan <[email protected]>, Jun Rao <[email protected]>
@jolshan
Copy link
Member

jolshan commented Sep 12, 2025

Can we include the jira in the pr title?

@jolshan
Copy link
Member

jolshan commented Sep 12, 2025

We also need to remove 4.0 specific code:

[Error] /home/jenkins/jenkins-agent/workspace/Kafka_kafka-pr_PR-20529/core/src/test/scala/unit/kafka/coordinator/transaction/TransactionStateManagerTest.scala:963:122: not found: value TV_2
--
  |   |   | [Error] /home/jenkins/jenkins-agent/workspace/Kafka_kafka-pr_PR-20529/core/src/test/scala/unit/kafka/coordinator/transaction/TransactionStateManagerTest.scala:975:122: not found: value TV_2

@CalvinConfluent CalvinConfluent changed the title Fix TransactionStateManager handling of empty batch when loading transaction metadata (#17688) KAFKA-17941: Fix TransactionStateManager handling of empty batch when loading transaction metadata (#17688) Sep 12, 2025
@jolshan jolshan merged commit 17157ed into apache:3.9 Sep 17, 2025
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants