Skip to content

KAFKA-19082:[4/4] Complete Txn Client Side Changes (KIP-939)#19714

Merged
jolshan merged 7 commits intoapache:trunkfrom
rreddy-22:KAFKA-19082-CompleteTxn-Client-changes-Pt4
May 29, 2025
Merged

KAFKA-19082:[4/4] Complete Txn Client Side Changes (KIP-939)#19714
jolshan merged 7 commits intoapache:trunkfrom
rreddy-22:KAFKA-19082-CompleteTxn-Client-changes-Pt4

Conversation

@rreddy-22
Copy link
Copy Markdown
Contributor

@rreddy-22 rreddy-22 commented May 13, 2025

public void completeTransaction(PreparedTxnState preparedTxnState)

The method compares the currently prepared transaction state and the
state passed in the argument.

  1. Commit if the state matches
  2. Abort the transaction otherwise.

If the producer is not in a prepared state (i.e., neither
prepareTransaction was called nor initTransaction(true) was called), we
return an INVALID_TXN_STATE error.

Reviewers: Justine Olshan jolshan@confluent.io, Artem Livshits
alivshits@confluent.io

@github-actions github-actions Bot added triage PRs from the community producer clients labels May 13, 2025
@rreddy-22 rreddy-22 force-pushed the KAFKA-19082-CompleteTxn-Client-changes-Pt4 branch from db9191b to 18c6d6f Compare May 14, 2025 23:22
@rreddy-22 rreddy-22 marked this pull request as ready for review May 14, 2025 23:23
@jolshan jolshan added ci-approved and removed triage PRs from the community labels May 14, 2025
Comment thread clients/src/main/java/org/apache/kafka/clients/producer/KafkaProducer.java Outdated
* If they match, the transaction is committed; otherwise, it is aborted.
*
* @param preparedTxnState The prepared transaction state to compare against the current state
* @throws IllegalStateException if the producer is not in prepared transaction state
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

what is the difference between IlegalState and InvalidTxnState?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ah my bad, I didn't change the Javadoc, illegalState. From my understanding, IllegalStateException is used when the producer is in an incorrect state and cannot use the API?
InvalidTxnStateException is used for when the transaction is in the wrong state.

Copy link
Copy Markdown
Member

@jolshan jolshan left a comment

Choose a reason for hiding this comment

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

lgtm thanks!

Copy link
Copy Markdown
Contributor

@artemlivshits artemlivshits left a comment

Choose a reason for hiding this comment

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

LGTM

@jolshan jolshan merged commit f42abe6 into apache:trunk May 29, 2025
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants