Skip to content

KAFKA-9293; Fix NPE in DumpLogSegments offsets parser and display tombstone keys - #7820

Merged
hachikuji merged 2 commits into
apache:trunkfrom
hachikuji:KAFKA-9293
Jan 3, 2020
Merged

KAFKA-9293; Fix NPE in DumpLogSegments offsets parser and display tombstone keys#7820
hachikuji merged 2 commits into
apache:trunkfrom
hachikuji:KAFKA-9293

Conversation

@hachikuji

Copy link
Copy Markdown
Contributor

Fixes an NPE when UserData in a member's subscription is null. Also modifies the output logic so that we show the keys of tombstones for both group and transaction metadata. Also adds test cases.

Committer Checklist (excluded from commit message)

  • Verify design and implementation
  • Verify test coverage and CI build status
  • Verify documentation (including upgrade notes)

/**
* Exposed for printing records using [[kafka.tools.DumpLogSegments]]
*/
def formatRecordKeyAndValue(record: Record): (Option[String], Option[String]) = {

@mumrah mumrah Jan 2, 2020

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can one or the other string be missing? Or will they always be present or absent together? Just wondering if this should be Option[Pair[String, String]] or something

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I agree the API is a bit awkward, but I think both cases are possible. For example, a tombstone will have a key, but not a value.

val txnKey = TransactionLog.readTxnRecordKey(record.key)
val keyString = s"transaction_metadata::transactionalId=${txnKey.transactionalId}"

val txnMetadata = TransactionLog.readTxnRecordValue(txnKey.transactionalId, record.value)

@mumrah mumrah Jan 2, 2020

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should we change readTxnRecordValue to return an Option? Glancing at that code, it looks like another possible NPE in TransactionStateManager#loadTransactions

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah, good suggestion. Pushed a change.

@mumrah mumrah left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM 👍

@hachikuji
hachikuji merged commit a094504 into apache:trunk Jan 3, 2020
hachikuji added a commit that referenced this pull request Jan 3, 2020
…bstone keys (#7820)

Fixes an NPE when UserData in a member's subscription is null and adds similar checks for transaction log parser. Also modifies the output logic so that we show the keys of tombstones for both group and transaction metadata.

Reviewers: David Arthur <mumrah@gmail.com>
qq619618919 pushed a commit to qq619618919/kafka that referenced this pull request May 12, 2020
…bstone keys (apache#7820)

Fixes an NPE when UserData in a member's subscription is null and adds similar checks for transaction log parser. Also modifies the output logic so that we show the keys of tombstones for both group and transaction metadata.

Reviewers: David Arthur <mumrah@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants