Skip to content

KAFKA-9492; Ignore record errors in ProduceResponse for older versions#8030

Merged
rajinisivaram merged 2 commits intoapache:trunkfrom
rajinisivaram:KAFKA-9492-produce-npe
Feb 4, 2020
Merged

KAFKA-9492; Ignore record errors in ProduceResponse for older versions#8030
rajinisivaram merged 2 commits intoapache:trunkfrom
rajinisivaram:KAFKA-9492-produce-npe

Conversation

@rajinisivaram
Copy link
Copy Markdown
Contributor

@rajinisivaram rajinisivaram commented Feb 1, 2020

f41a5c2 caused a regression in version compatibility. We populate record errors in ProduceResponse regardless of the request version. ProduceResponse.toStruct(version) was attempting to populate record_errors if errors were present without checking if the version supported this. This PR adds a version check.

Committer Checklist (excluded from commit message)

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

@ijuma
Copy link
Copy Markdown
Member

ijuma commented Feb 2, 2020

@rajinisivaram can you please include a reference to the commit where the behavior regressed?

@ijuma ijuma requested a review from guozhangwang February 2, 2020 10:55
Copy link
Copy Markdown
Member

@ijuma ijuma left a comment

Choose a reason for hiding this comment

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

LGTM, just a minor comment. It would be good for @guozhangwang and/or @tuvtran to double-check since they worked on the original change (f41a5c2, in particular, was meant to address the compatibility issue).

}

@Test
public void produceResponseRecordErrorsTest() {
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.

Maybe this should be in ProduceResponseTest? We started writing this type of test in dedicated classes as this class was getting too large.

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.

@ijuma Thanks for the review. I have moved this test and the other two produce response tests to ProduceResponseTest.

Errors error = Errors.forCode(partRespStruct.get(ERROR_CODE));
long offset = partRespStruct.getLong(BASE_OFFSET_KEY_NAME);
long logAppendTime = partRespStruct.getLong(LOG_APPEND_TIME_KEY_NAME);
long logAppendTime = partRespStruct.hasField(LOG_APPEND_TIME_KEY_NAME) ?
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 convert the type of LOG_APPEND_TIME_KEY_NAME from long to Field.Int64? the benefit of using Field.Int64 is shown below.

  1. remove the duplicate code of converting LOG_APPEND_TIME_KEY_NAME to Field.Int64
  2. use more readable method - getOrElse

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.

@chia7712 Thanks for the review. As @hachikuji mentioned, we can convert to use the generated classes, so will leave that for a separate PR.

Copy link
Copy Markdown
Contributor

@hachikuji hachikuji left a comment

Choose a reason for hiding this comment

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

LGTM. I think @chia7712 's suggestions make sense, but could be done in a follow-up. Even better would be to finally convert this protocol since the generated classes now support ByteBuffer.

Copy link
Copy Markdown
Contributor

@guozhangwang guozhangwang left a comment

Choose a reason for hiding this comment

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

Lgtm. Thanks for the catch.

Copy link
Copy Markdown
Member

@ijuma ijuma left a comment

Choose a reason for hiding this comment

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

LGTM

@rajinisivaram
Copy link
Copy Markdown
Contributor Author

@chia7712 @ijuma @hachikuji @guozhangwang Thanks for the reviews. Test failures are unrelated, merging to trunk, 2.5 and 2.4.

@rajinisivaram rajinisivaram merged commit 281ed90 into apache:trunk Feb 4, 2020
rajinisivaram added a commit that referenced this pull request Feb 4, 2020
#8030)

Fixes NPE in brokers when processing record errors in produce response for older versions.

Reviewers: Chia-Ping Tsai <chia7712@gmail.com>, Ismael Juma <ismael@juma.me.uk>, Jason Gustafson <jason@confluent.io>, Guozhang Wang <wangguoz@gmail.com>
rajinisivaram added a commit that referenced this pull request Feb 4, 2020
#8030)

Fixes NPE in brokers when processing record errors in produce response for older versions.

Reviewers: Chia-Ping Tsai <chia7712@gmail.com>, Ismael Juma <ismael@juma.me.uk>, Jason Gustafson <jason@confluent.io>, Guozhang Wang <wangguoz@gmail.com>
ijuma added a commit to confluentinc/kafka that referenced this pull request Feb 7, 2020
Conflicts:
* build.gradle: moved avro plugin definition below
newly added test retry plugin.

* apache-github/trunk:
  MINOR: further InternalTopologyBuilder cleanup  (apache#8046)
  MINOR: Add timer for update limit offsets (apache#8047)
  HOTFIX: Fix spotsbug failure in Kafka examples (apache#8051)
  KAFKA-9447: Add new customized EOS model example (apache#8031)
  KAFKA-8164: Add support for retrying failed (apache#8019)
  HOTFIX: checkstyle for newly added unit test
  KAFKA-9261; Client should handle unavailable leader metadata (apache#7770)
  MINOR: Fix typos introduced in KIP-559 (apache#8042)
  MINOR: Fixing null handilg in ValueAndTimestampSerializer (apache#7679)
  KAFKA-9113: Clean up task management and state management (apache#7997)
  MINOR: fix checkstyle issue in ConsumerConfig.java (apache#8038)
  KAFKA-9491; Increment high watermark after full log truncation (apache#8037)
  KAFKA-9477 Document RoundRobinAssignor as an option for partition.assignment.strategy (apache#8007)
  KAFKA-9074: Correct Connect’s `Values.parseString` to properly parse a time and timestamp literal (apache#7568)
  KAFKA-9492; Ignore record errors in ProduceResponse for older versions (apache#8030)
stanislavkozlovski pushed a commit to stanislavkozlovski/kafka that referenced this pull request Feb 18, 2020
apache#8030)

Fixes NPE in brokers when processing record errors in produce response for older versions.

Reviewers: Chia-Ping Tsai <chia7712@gmail.com>, Ismael Juma <ismael@juma.me.uk>, Jason Gustafson <jason@confluent.io>, Guozhang Wang <wangguoz@gmail.com>
qq619618919 pushed a commit to qq619618919/kafka that referenced this pull request May 12, 2020
apache#8030)

Fixes NPE in brokers when processing record errors in produce response for older versions.

Reviewers: Chia-Ping Tsai <chia7712@gmail.com>, Ismael Juma <ismael@juma.me.uk>, Jason Gustafson <jason@confluent.io>, Guozhang Wang <wangguoz@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.

5 participants