Skip to content

Commit faad21f

Browse files
authored
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]>
1 parent 06c9213 commit faad21f

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

clients/src/main/java/org/apache/kafka/common/requests/WriteTxnMarkersRequest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@ public Builder(WriteTxnMarkersRequestData data) {
110110
}
111111

112112
public Builder(final List<TxnMarkerEntry> markers) {
113-
super(ApiKeys.WRITE_TXN_MARKERS, (short) 1); // if we add new versions, gate them behind metadata version
113+
// version will be determined at build time based on broker capabilities
114+
super(ApiKeys.WRITE_TXN_MARKERS);
114115
List<WritableTxnMarker> dataMarkers = new ArrayList<>();
115116
for (TxnMarkerEntry marker : markers) {
116117
final Map<String, WritableTxnMarkerTopic> topicMap = new HashMap<>();

clients/src/main/resources/common/message/WriteTxnMarkersRequest.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
// Version 0 was removed in Apache Kafka 4.0, Version 1 is the new baseline.
2222
//
2323
// Version 1 enables flexible versions.
24-
"validVersions": "1",
24+
// Version 2 adds TransactionVersion field to the WritableTxnMarker (KIP-1228).
25+
"validVersions": "1-2",
2526
"flexibleVersions": "1+",
2627
"fields": [
2728
{ "name": "Markers", "type": "[]WritableTxnMarker", "versions": "0+",
@@ -40,7 +41,9 @@
4041
"about": "The indexes of the partitions to write transaction markers for." }
4142
]},
4243
{ "name": "CoordinatorEpoch", "type": "int32", "versions": "0+",
43-
"about": "Epoch associated with the transaction state partition hosted by this transaction coordinator." }
44+
"about": "Epoch associated with the transaction state partition hosted by this transaction coordinator." },
45+
{ "name": "TransactionVersion", "type": "int8", "versions": "2+", "ignorable": true,
46+
"about": "Transaction version of the marker. Ex: 0/1 = legacy (TV0/TV1), 2 = TV2 etc.", "default": "0" }
4447
]}
4548
]
4649
}

clients/src/main/resources/common/message/WriteTxnMarkersResponse.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@
1717
"apiKey": 27,
1818
"type": "response",
1919
"name": "WriteTxnMarkersResponse",
20-
"validVersions": "1",
20+
"validVersions": "1-2",
2121
// Version 0 was removed in Apache Kafka 4.0, Version 1 is the new baseline.
2222
//
2323
// Version 1 enables flexible versions.
24+
// Version 2 matches WriteTxnMarkersRequest version 2 (KIP-1228).
2425
"flexibleVersions": "1+",
2526
"fields": [
2627
{ "name": "Markers", "type": "[]WritableTxnMarkerResult", "versions": "0+",

0 commit comments

Comments
 (0)