KAFKA-20712: Fix transaction state name in log decoder output#22615
Open
fvaleri wants to merge 1 commit into
Open
KAFKA-20712: Fix transaction state name in log decoder output#22615fvaleri wants to merge 1 commit into
fvaleri wants to merge 1 commit into
Conversation
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. Signed-off-by: Federico Valeri <fedevaleri@gmail.com>
Contributor
Author
|
I also ran the following manual tests: # 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]},{"topic":"__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}}} |
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.