Skip to content

KAFKA-19069: DumpLogSegments does not dump the LEADER_CHANGE record #19729

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
May 23, 2025

Conversation

Yunyung
Copy link
Collaborator

@Yunyung Yunyung commented May 15, 2025

Description:

Add case for dumping LEADER_CHANGE record in DumpLogSegments.

  • Extract the part of printing ControlRecord as a method.
  • Add the unit test for printing the control record in dumpLog.

Verification

Before:

$ bin/kafka-dump-log.sh --cluster-metadata-decoder --files
try_KAFKA-19069/00000000000000000000.log
Dumping try_KAFKA-19069/00000000000000000000.log
Log starting offset: 0
baseOffset: 0 lastOffset: 2 count: 3 baseSequence: -1 lastSequence: -1
producerId: -1 producerEpoch: -1 partitionLeaderEpoch: 1
isTransactional: false isControl: true deleteHorizonMs:
OptionalLong.empty position: 0 CreateTime: 1747299887693 size: 174
magic: 2 compresscodec: none crc: 3714449884 isvalid: true
| offset: 0 CreateTime: 1747299887693 keySize: 4 valueSize: 19 sequence:
-1 headerKeys: [] controlType: LEADER_CHANGE(2)
| offset: 1 CreateTime: 1747299887693 keySize: 4 valueSize: 5 sequence:
-1 headerKeys: [] KRaftVersion {"version":0,"kRaftVersion":1}
| offset: 2 CreateTime: 1747299887693 keySize: 4 valueSize: 55 sequence:
-1 headerKeys: [] KRaftVoters
{"version":0,"voters":[{"voterId":1,"voterDirectoryId":"tpx8pd1IQDqJwMfGzXj6GA","endpoints":[{"name":"CONTROLLER","host":"localhost","port":9093}],"kRaftVersionFeature":{"minSupportedVersion":0,"maxSupportedVersion":1}}]}

After:

$ bin/kafka-dump-log.sh --cluster-metadata-decoder --files
try_KAFKA-19069/00000000000000000000.log
Dumping try_KAFKA-19069/00000000000000000000.log
Log starting offset: 0
baseOffset: 0 lastOffset: 2 count: 3 baseSequence: -1 lastSequence: -1
producerId: -1 producerEpoch: -1 partitionLeaderEpoch: 1
isTransactional: false isControl: true deleteHorizonMs:
OptionalLong.empty position: 0 CreateTime: 1747299887693 size: 174
magic: 2 compresscodec: none crc: 3714449884 isvalid: true
| offset: 0 CreateTime: 1747299887693 keySize: 4 valueSize: 19 sequence:
-1 headerKeys: [] leaderChange:
{"version":0,"leaderId":1,"voters":[{"voterId":1}],"grantingVoters":[{"voterId":1}]}
| offset: 1 CreateTime: 1747299887693 keySize: 4 valueSize: 5 sequence:
-1 headerKeys: [] KRaftVersion {"version":0,"kRaftVersion":1}
| offset: 2 CreateTime: 1747299887693 keySize: 4 valueSize: 55 sequence:
-1 headerKeys: [] KRaftVoters
{"version":0,"voters":[{"voterId":1,"voterDirectoryId":"tpx8pd1IQDqJwMfGzXj6GA","endpoints":[{"name":"CONTROLLER","host":"localhost","port":9093}],"kRaftVersionFeature":{"minSupportedVersion":0,"maxSupportedVersion":1}}]}

Reviewers: PoAn Yang payang@apache.org, Chia-Ping Tsai
chia7712@gmail.com

@github-actions github-actions bot added triage PRs from the community core Kafka Broker small Small PRs labels May 15, 2025
Copy link
Member

@FrankYang0529 FrankYang0529 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the patch. Could you add related test case?

@github-actions github-actions bot removed the triage PRs from the community label May 16, 2025
@Yunyung
Copy link
Collaborator Author

Yunyung commented May 22, 2025

Thanks for the patch. Could you add related test case?

Done. Thanks.

@@ -351,6 +333,32 @@ object DumpLogSegments {
} finally fileRecords.closeHandlers()
}

private[tools] def printControlRecord(record: Record): Unit = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't need to add [tools], right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right! Done, thanks.

@chia7712 chia7712 merged commit 999afbb into apache:trunk May 23, 2025
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci-approved core Kafka Broker small Small PRs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants