This is an automated email from the ASF dual-hosted git repository.
schofielaj pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/kafka.git
The following commit(s) were added to refs/heads/trunk by this push:
new faad21fcb9a KAFKA-19446: Add transaction version field [1/3] (#20857)
faad21fcb9a is described below
commit faad21fcb9a35b2d8682951024c8eb1a714ca355
Author: Ritika Reddy <[email protected]>
AuthorDate: Wed Nov 12 12:32:20 2025 -0800
KAFKA-19446: Add transaction version field [1/3] (#20857)
Simple PR to add the transaction version field to the WriteTxnMarkers
Request in order to enable KIP-1228. We are bumping the API version to
version 2.
Reviewers: Artem Livshits <[email protected]>, Andrew Schofield
<[email protected]>
---
.../org/apache/kafka/common/requests/WriteTxnMarkersRequest.java | 3 ++-
.../src/main/resources/common/message/WriteTxnMarkersRequest.json | 7 +++++--
.../src/main/resources/common/message/WriteTxnMarkersResponse.json | 3 ++-
3 files changed, 9 insertions(+), 4 deletions(-)
diff --git
a/clients/src/main/java/org/apache/kafka/common/requests/WriteTxnMarkersRequest.java
b/clients/src/main/java/org/apache/kafka/common/requests/WriteTxnMarkersRequest.java
index d7b0f30eb39..38f416654f2 100644
---
a/clients/src/main/java/org/apache/kafka/common/requests/WriteTxnMarkersRequest.java
+++
b/clients/src/main/java/org/apache/kafka/common/requests/WriteTxnMarkersRequest.java
@@ -110,7 +110,8 @@ public class WriteTxnMarkersRequest extends AbstractRequest
{
}
public Builder(final List<TxnMarkerEntry> markers) {
- super(ApiKeys.WRITE_TXN_MARKERS, (short) 1); // if we add new
versions, gate them behind metadata version
+ // version will be determined at build time based on broker
capabilities
+ super(ApiKeys.WRITE_TXN_MARKERS);
List<WritableTxnMarker> dataMarkers = new ArrayList<>();
for (TxnMarkerEntry marker : markers) {
final Map<String, WritableTxnMarkerTopic> topicMap = new
HashMap<>();
diff --git
a/clients/src/main/resources/common/message/WriteTxnMarkersRequest.json
b/clients/src/main/resources/common/message/WriteTxnMarkersRequest.json
index cacda4198e4..1fb3e050e16 100644
--- a/clients/src/main/resources/common/message/WriteTxnMarkersRequest.json
+++ b/clients/src/main/resources/common/message/WriteTxnMarkersRequest.json
@@ -21,7 +21,8 @@
// Version 0 was removed in Apache Kafka 4.0, Version 1 is the new baseline.
//
// Version 1 enables flexible versions.
- "validVersions": "1",
+ // Version 2 adds TransactionVersion field to the WritableTxnMarker
(KIP-1228).
+ "validVersions": "1-2",
"flexibleVersions": "1+",
"fields": [
{ "name": "Markers", "type": "[]WritableTxnMarker", "versions": "0+",
@@ -40,7 +41,9 @@
"about": "The indexes of the partitions to write transaction markers
for." }
]},
{ "name": "CoordinatorEpoch", "type": "int32", "versions": "0+",
- "about": "Epoch associated with the transaction state partition hosted
by this transaction coordinator." }
+ "about": "Epoch associated with the transaction state partition hosted
by this transaction coordinator." },
+ { "name": "TransactionVersion", "type": "int8", "versions": "2+",
"ignorable": true,
+ "about": "Transaction version of the marker. Ex: 0/1 = legacy
(TV0/TV1), 2 = TV2 etc.", "default": "0" }
]}
]
}
diff --git
a/clients/src/main/resources/common/message/WriteTxnMarkersResponse.json
b/clients/src/main/resources/common/message/WriteTxnMarkersResponse.json
index 72c5e30c368..2a1186d479b 100644
--- a/clients/src/main/resources/common/message/WriteTxnMarkersResponse.json
+++ b/clients/src/main/resources/common/message/WriteTxnMarkersResponse.json
@@ -17,10 +17,11 @@
"apiKey": 27,
"type": "response",
"name": "WriteTxnMarkersResponse",
- "validVersions": "1",
+ "validVersions": "1-2",
// Version 0 was removed in Apache Kafka 4.0, Version 1 is the new baseline.
//
// Version 1 enables flexible versions.
+ // Version 2 matches WriteTxnMarkersRequest version 2 (KIP-1228).
"flexibleVersions": "1+",
"fields": [
{ "name": "Markers", "type": "[]WritableTxnMarkerResult", "versions": "0+",