Skip to content

KAFKA-20738: Producer 2PC InitProducerId request must negotiate v6#22703

Open
Shekharrajak wants to merge 2 commits into
apache:trunkfrom
Shekharrajak:KAFKA-20738-producer-2pc-initproducerid-version
Open

KAFKA-20738: Producer 2PC InitProducerId request must negotiate v6#22703
Shekharrajak wants to merge 2 commits into
apache:trunkfrom
Shekharrajak:KAFKA-20738-producer-2pc-initproducerid-version

Conversation

@Shekharrajak

@Shekharrajak Shekharrajak commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Ref https://issues.apache.org/jira/browse/KAFKA-20738

A producer with transaction.two.phase.commit.enable=true fails initTransactions() with UnsupportedVersionException: Attempted to write a non-default enable2Pc at version 5.

Root cause: v6 is latestVersionUnstable, the builder caps latestAllowedVersion at 5, so NetworkClient can never negotiate v6.

Fix: When enable2Pc or keepPreparedTxn is set, the builder allows the unstable last version (v6) so v6 is negotiated against a capable broker. Plain producers are unaffected (still capped at v5). build() now throws a clear UnsupportedVersionException if the negotiated version is < 6 while a 2PC field is set, instead of leaking the serialization-internals message.

Tests: Added InitProducerIdRequestTest covering latestAllowedVersion == 6 when enable2Pc/keepPreparedTxn is set, and the v5 cap for non-2PC requests.

Note: this is the client-side half; broker-side keepPreparedTxn recovery is tracked in KAFKA-20739 #22704
Reviewers: Andrew Schofield aschofield@confluent.io

@github-actions github-actions Bot added triage PRs from the community clients small Small PRs labels Jun 29, 2026
@Shekharrajak

Copy link
Copy Markdown
Contributor Author

Ref #22704

@AndrewJSchofield AndrewJSchofield left a comment

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.

I don't think this is a problem that needs a fix. It's a reflection of the partial implementation of KIP-939. The latest RPC version is marked as unstable so that production clusters do not accidentally support 2PC.

@github-actions github-actions Bot removed the triage PRs from the community label Jun 30, 2026
@Shekharrajak

Copy link
Copy Markdown
Contributor Author

I don't think this is a problem that needs a fix. It's a reflection of the partial implementation of KIP-939. The latest RPC version is marked as unstable so that production clusters do not accidentally support 2PC.

Thanks @AndrewJSchofield for checking. Let me follow it closely https://issues.apache.org/jira/browse/KAFKA-15370

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants