You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "fvaleri (via GitHub)" <gi...@apache.org> on 2026/06/18 10:48:34 UTC
[PR] KAFKA-20712: Fix transaction state name in log decoder output [kafka]
fvaleri opened a new pull request, #22615:
URL: https://github.com/apache/kafka/pull/22615
The TransactionLogMessageParser and TransactionLogMessageFormatter output the numeric transactionStatus (e.g. 4) instead of the human readable state name (e.g. CompleteCommit). This was caused by the migration to auto generated CoordinatorRecordJsonConverters which serialize the int8 field as is. Resolve the byte to the state name via TransactionState.fromId() in both the dump log and consumer formatter code paths.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-20712: Fix transaction state name in log decoder output [kafka]
Posted by "fvaleri (via GitHub)" <gi...@apache.org>.
fvaleri commented on PR #22615:
URL: https://github.com/apache/kafka/pull/22615#issuecomment-4741253915
@chia7712 @dajac fyi
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-20712: Fix transaction state name in log decoder output [kafka]
Posted by "fvaleri (via GitHub)" <gi...@apache.org>.
fvaleri commented on code in PR #22615:
URL: https://github.com/apache/kafka/pull/22615#discussion_r3504318314
##########
tools/src/main/java/org/apache/kafka/tools/DumpLogSegments.java:
##########
@@ -725,8 +727,13 @@ protected JsonNode keyAsJson(ApiMessage message) {
@Override
protected JsonNode valueAsJson(ApiMessage message, short version) {
- return org.apache.kafka.coordinator.transaction.generated.CoordinatorRecordJsonConverters
+ JsonNode json = org.apache.kafka.coordinator.transaction.generated.CoordinatorRecordJsonConverters
.writeRecordValueAsJson(message, version);
+ if (message instanceof TransactionLogValue) {
+ ((ObjectNode) json).put("transactionStatus",
+ TransactionState.fromId(((TransactionLogValue) message).transactionStatus()).stateName());
Review Comment:
@chia7712 I would say that we can catch the exception and fall back to the numeric value. This is what I do in my latest commit. Let me know if it's fine or you had something different in mind. Thanks.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-20712: Fix transaction state name in log decoder output [kafka]
Posted by "fvaleri (via GitHub)" <gi...@apache.org>.
fvaleri commented on code in PR #22615:
URL: https://github.com/apache/kafka/pull/22615#discussion_r3504318314
##########
tools/src/main/java/org/apache/kafka/tools/DumpLogSegments.java:
##########
@@ -725,8 +727,13 @@ protected JsonNode keyAsJson(ApiMessage message) {
@Override
protected JsonNode valueAsJson(ApiMessage message, short version) {
- return org.apache.kafka.coordinator.transaction.generated.CoordinatorRecordJsonConverters
+ JsonNode json = org.apache.kafka.coordinator.transaction.generated.CoordinatorRecordJsonConverters
.writeRecordValueAsJson(message, version);
+ if (message instanceof TransactionLogValue) {
+ ((ObjectNode) json).put("transactionStatus",
+ TransactionState.fromId(((TransactionLogValue) message).transactionStatus()).stateName());
Review Comment:
@chia7712 I would say that we can catch the exception and fall back to the numeric value. This is what I do in my latest commit. Let me know if it's fine or you had something different in mind.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-20712: Fix transaction state name in log decoder output [kafka]
Posted by "chia7712 (via GitHub)" <gi...@apache.org>.
chia7712 merged PR #22615:
URL: https://github.com/apache/kafka/pull/22615
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-20712: Fix transaction state name in log decoder output [kafka]
Posted by "fvaleri (via GitHub)" <gi...@apache.org>.
fvaleri commented on PR #22615:
URL: https://github.com/apache/kafka/pull/22615#issuecomment-4750803223
@showuon The commit that broke this is 3fafa096b1 (KAFKA-18207) not the migration to the auto generated converters, sorry for the confusion. readTxnRecordValue resolved the byte to the enum via TransactionState.fromId(value.transactionStatus).
https://github.com/apache/kafka/blob/3fafa096b113ee3bc9c9472e6aa5dfd2e46b7352/core/src/main/scala/kafka/coordinator/transaction/TransactionLog.scala#L129
and then
https://github.com/apache/kafka/blob/09e36fdfd4f025f4c6fd71a0e9e476f88d888b28/transaction-coordinator/src/main/java/org/apache/kafka/coordinator/transaction/TransactionState.java#L158C45-L158C52
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-20712: Fix transaction state name in log decoder output [kafka]
Posted by "fvaleri (via GitHub)" <gi...@apache.org>.
fvaleri commented on code in PR #22615:
URL: https://github.com/apache/kafka/pull/22615#discussion_r3504318314
##########
tools/src/main/java/org/apache/kafka/tools/DumpLogSegments.java:
##########
@@ -725,8 +727,13 @@ protected JsonNode keyAsJson(ApiMessage message) {
@Override
protected JsonNode valueAsJson(ApiMessage message, short version) {
- return org.apache.kafka.coordinator.transaction.generated.CoordinatorRecordJsonConverters
+ JsonNode json = org.apache.kafka.coordinator.transaction.generated.CoordinatorRecordJsonConverters
.writeRecordValueAsJson(message, version);
+ if (message instanceof TransactionLogValue) {
+ ((ObjectNode) json).put("transactionStatus",
+ TransactionState.fromId(((TransactionLogValue) message).transactionStatus()).stateName());
Review Comment:
@chia7712 I would say that we can catch the exception and fall back to the numeric value. This is what I do in my latest commit.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-20712: Fix transaction state name in log decoder output [kafka]
Posted by "fvaleri (via GitHub)" <gi...@apache.org>.
fvaleri commented on PR #22615:
URL: https://github.com/apache/kafka/pull/22615#issuecomment-4741247522
I also ran a manual test:
```sh
# DECODER
$ bin/kafka-dump-log.sh --transaction-log-decoder \
--files build/test/server3/data/__transaction_state-30/00000000000000000000.log
Dumping build/test/server3/data/__transaction_state-30/00000000000000000000.log
Log starting offset: 0
baseOffset: 0 lastOffset: 0 count: 1 baseSequence: -1 lastSequence: -1 producerId: -1 producerEpoch: -1 partitionLeaderEpoch: 0 isTransactional: false isControl: false deleteHorizonMs: OptionalLong.empty position: 0 CreateTime: 1781778768196 size: 129 magic: 2 compresscodec: none crc: 326836132 isvalid: true
| offset: 0 CreateTime: 1781778768196 keySize: 15 valueSize: 45 sequence: -1 headerKeys: [] key: {"type":"0","data":{"transactionalId":"kafka-txn-0"}} payload: {"version":"1","data":{"producerId":0,"previousProducerId":0,"producerEpoch":0,"transactionTimeoutMs":60000,"transactionStatus":"Empty","transactionPartitions":null,"transactionLastUpdateTimestampMs":1781778768194,"transactionStartTimestampMs":-1}}
baseOffset: 1 lastOffset: 1 count: 1 baseSequence: -1 lastSequence: -1 producerId: -1 producerEpoch: -1 partitionLeaderEpoch: 0 isTransactional: false isControl: false deleteHorizonMs: OptionalLong.empty position: 129 CreateTime: 1781778790949 size: 159 magic: 2 compresscodec: none crc: 3923950402 isvalid: true
| offset: 1 CreateTime: 1781778790949 keySize: 15 valueSize: 74 sequence: -1 headerKeys: [] key: {"type":"0","data":{"transactionalId":"kafka-txn-0"}} payload: {"version":"1","data":{"producerId":0,"previousProducerId":0,"producerEpoch":0,"transactionTimeoutMs":60000,"transactionStatus":"Ongoing","transactionPartitions":[{"topic":"__consumer_offsets","partitionIds":[12]}],"transactionLastUpdateTimestampMs":1781778790949,"transactionStartTimestampMs":1781778790949,"clientTransactionVersion":2}}
baseOffset: 2 lastOffset: 2 count: 1 baseSequence: -1 lastSequence: -1 producerId: -1 producerEpoch: -1 partitionLeaderEpoch: 0 isTransactional: false isControl: false deleteHorizonMs: OptionalLong.empty position: 288 CreateTime: 1781778790976 size: 178 magic: 2 compresscodec: none crc: 2885873356 isvalid: true
| offset: 2 CreateTime: 1781778790976 keySize: 15 valueSize: 93 sequence: -1 headerKeys: [] key: {"type":"0","data":{"transactionalId":"kafka-txn-0"}} payload: {"version":"1","data":{"producerId":0,"previousProducerId":0,"producerEpoch":0,"transactionTimeoutMs":60000,"transactionStatus":"Ongoing","transactionPartitions":[{"topic":"output-topic","partitionIds":[0]},{"topic":"__consumer_offsets","partitionIds":[12]}],"transactionLastUpdateTimestampMs":1781778790976,"transactionStartTimestampMs":1781778790949,"clientTransactionVersion":2}}
baseOffset: 3 lastOffset: 3 count: 1 baseSequence: -1 lastSequence: -1 producerId: -1 producerEpoch: -1 partitionLeaderEpoch: 0 isTransactional: false isControl: false deleteHorizonMs: OptionalLong.empty position: 466 CreateTime: 1781778791003 size: 178 magic: 2 compresscodec: none crc: 2328565620 isvalid: true
| offset: 3 CreateTime: 1781778791003 keySize: 15 valueSize: 93 sequence: -1 headerKeys: [] key: {"type":"0","data":{"transactionalId":"kafka-txn-0"}} payload: {"version":"1","data":{"producerId":0,"previousProducerId":0,"producerEpoch":1,"transactionTimeoutMs":60000,"transactionStatus":"PrepareCommit","transactionPartitions":[{"topic":"output-topic","partitionIds":[0]},{"topic":"__consumer_offsets","partitionIds":[12]}],"transactionLastUpdateTimestampMs":1781778791003,"transactionStartTimestampMs":1781778790949,"clientTransactionVersion":2}}
baseOffset: 4 lastOffset: 4 count: 1 baseSequence: -1 lastSequence: -1 producerId: -1 producerEpoch: -1 partitionLeaderEpoch: 0 isTransactional: false isControl: false deleteHorizonMs: OptionalLong.empty position: 644 CreateTime: 1781778791028 size: 133 magic: 2 compresscodec: none crc: 3554341315 isvalid: true
| offset: 4 CreateTime: 1781778791028 keySize: 15 valueSize: 49 sequence: -1 headerKeys: [] key: {"type":"0","data":{"transactionalId":"kafka-txn-0"}} payload: {"version":"1","data":{"producerId":0,"previousProducerId":0,"producerEpoch":1,"transactionTimeoutMs":60000,"transactionStatus":"CompleteCommit","transactionPartitions":[],"transactionLastUpdateTimestampMs":1781778791008,"transactionStartTimestampMs":1781778790949,"clientTransactionVersion":2}}
# FORMATTER
$ bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic __transaction_state --from-beginning \
--formatter org.apache.kafka.tools.consumer.TransactionLogMessageFormatter 2>/dev/null
{"key":{"type":0,"data":{"transactionalId":"kafka-txn-0"}},"value":{"version":1,"data":{"producerId":0,"previousProducerId":0,"producerEpoch":0,"transactionTimeoutMs":60000,"transactionStatus":"Empty","transactionPartitions":null,"transactionLastUpdateTimestampMs":1781779953988,"transactionStartTimestampMs":-1}}}{"key":{"type":0,"data":{"transactionalId":"kafka-txn-0"}},"value":{"version":1,"data":{"producerId":0,"previousProducerId":0,"producerEpoch":0,"transactionTimeoutMs":60000,"transactionStatus":"Ongoing","transactionPartitions":[{"topic":"__consumer_offsets","partitionIds":[12]}],"transactionLastUpdateTimestampMs":1781779965937,"transactionStartTimestampMs":1781779965937,"clientTransactionVersion":2}}}{"key":{"type":0,"data":{"transactionalId":"kafka-txn-0"}},"value":{"version":1,"data":{"producerId":0,"previousProducerId":0,"producerEpoch":0,"transactionTimeoutMs":60000,"transactionStatus":"Ongoing","transactionPartitions":[{"topic":"output-topic","partitionIds":[1]},{"top
ic":"__consumer_offsets","partitionIds":[12]}],"transactionLastUpdateTimestampMs":1781779965967,"transactionStartTimestampMs":1781779965937,"clientTransactionVersion":2}}}{"key":{"type":0,"data":{"transactionalId":"kafka-txn-0"}},"value":{"version":1,"data":{"producerId":0,"previousProducerId":0,"producerEpoch":1,"transactionTimeoutMs":60000,"transactionStatus":"PrepareCommit","transactionPartitions":[{"topic":"output-topic","partitionIds":[1]},{"topic":"__consumer_offsets","partitionIds":[12]}],"transactionLastUpdateTimestampMs":1781779965993,"transactionStartTimestampMs":1781779965937,"clientTransactionVersion":2}}}{"key":{"type":0,"data":{"transactionalId":"kafka-txn-0"}},"value":{"version":1,"data":{"producerId":0,"previousProducerId":0,"producerEpoch":1,"transactionTimeoutMs":60000,"transactionStatus":"CompleteCommit","transactionPartitions":[],"transactionLastUpdateTimestampMs":1781779966000,"transactionStartTimestampMs":1781779965937,"clientTransactionVersion":2}}}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-20712: Fix transaction state name in log decoder output [kafka]
Posted by "jolshan (via GitHub)" <gi...@apache.org>.
jolshan commented on PR #22615:
URL: https://github.com/apache/kafka/pull/22615#issuecomment-4752968348
@fvaleri -- this was just breaking the readability of some outputs? Glad we fixed, but wanted to make sure I understood the impact.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-20712: Fix transaction state name in log decoder output [kafka]
Posted by "fvaleri (via GitHub)" <gi...@apache.org>.
fvaleri commented on PR #22615:
URL: https://github.com/apache/kafka/pull/22615#issuecomment-4753339587
> @fvaleri -- this was just breaking the readability of some outputs? Glad we fixed, but wanted to make sure I understood the impact.
Yes, it makes debugging harder, but we may also break some procedures that are parsing the tool's output as soon as they upgrade to 4.1+. It is also true that we may break some users on 4.1+ that have already created procedures parsing the new format. These tools are sometimes used in system tests, but that is not the case here. I checked.
Either way we may break some procedure, so I'm fine with your decision anyway. Thanks for the review.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-20712: Fix transaction state name in log decoder output [kafka]
Posted by "chia7712 (via GitHub)" <gi...@apache.org>.
chia7712 commented on code in PR #22615:
URL: https://github.com/apache/kafka/pull/22615#discussion_r3499195009
##########
tools/src/main/java/org/apache/kafka/tools/DumpLogSegments.java:
##########
@@ -725,8 +727,13 @@ protected JsonNode keyAsJson(ApiMessage message) {
@Override
protected JsonNode valueAsJson(ApiMessage message, short version) {
- return org.apache.kafka.coordinator.transaction.generated.CoordinatorRecordJsonConverters
+ JsonNode json = org.apache.kafka.coordinator.transaction.generated.CoordinatorRecordJsonConverters
.writeRecordValueAsJson(message, version);
+ if (message instanceof TransactionLogValue) {
+ ((ObjectNode) json).put("transactionStatus",
+ TransactionState.fromId(((TransactionLogValue) message).transactionStatus()).stateName());
Review Comment:
Should we consider forward compatibility? For example, if a newer version of Kafka adds a new `TransactionState`, what happens when a user uses an older version of the tool to parse the logs?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-20712: Fix transaction state name in log decoder output [kafka]
Posted by "fvaleri (via GitHub)" <gi...@apache.org>.
fvaleri commented on PR #22615:
URL: https://github.com/apache/kafka/pull/22615#issuecomment-4808593447
> Is there still a test failing?
Forgot one, sorry. Should be all good now.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-20712: Fix transaction state name in log decoder output [kafka]
Posted by "jolshan (via GitHub)" <gi...@apache.org>.
jolshan commented on PR #22615:
URL: https://github.com/apache/kafka/pull/22615#issuecomment-4804755001
Is there still a test failing?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-20712: Fix transaction state name in log decoder output [kafka]
Posted by "showuon (via GitHub)" <gi...@apache.org>.
showuon commented on PR #22615:
URL: https://github.com/apache/kafka/pull/22615#issuecomment-4750130415
LGTM! But could you point me the where the old behavior is changed? I'd like to know how the old behavior is. Thanks.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org