Skip to content

KAFKA-12701: NPE in MetadataRequest when using topic IDs#10584

Merged
ijuma merged 14 commits intoapache:trunkfrom
jolshan:KAFKA--12701
Jun 15, 2021
Merged

KAFKA-12701: NPE in MetadataRequest when using topic IDs#10584
ijuma merged 14 commits intoapache:trunkfrom
jolshan:KAFKA--12701

Conversation

@jolshan
Copy link
Member

@jolshan jolshan commented Apr 22, 2021

We prevent handling MetadataRequests where the topic name is null (to prevent NPE) as well as prevent requests that set topic IDs since this functionality has not yet been implemented. When we do implement in in #9769, we should bump the request/response version.

Should also cherry-pick these changes to 2.8 for the next release.

Added tests to ensure the error is thrown.

Committer Checklist (excluded from commit message)

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

@jolshan
Copy link
Member Author

jolshan commented Apr 22, 2021

Test failures look unrelated. Some of the usual suspects like RaftClusterTest.testCreateClusterAndCreateAndManyTopicsWithManyPartitions() and MirrorConnectorsIntegrationSSLTest/MirrorConnectorsIntegrationTesttests

Copy link
Member

@dengziming dengziming left a comment

Choose a reason for hiding this comment

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

I think this makes sense

Copy link
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.

Thanks for the PRs, left a few comments.

Copy link
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, a minor nit below.

@ijuma
Copy link
Member

ijuma commented Jun 11, 2021

I think you need to merge master to this branch or rebase this branch on master. Jenkins is failing due to:

[2021-06-10T21:42:48.226Z] [Error] /home/jenkins/jenkins-agent/workspace/Kafka_kafka-pr_PR-10584/core/src/test/scala/unit/kafka/server/KafkaApisTest.scala:1082: not enough arguments for method handle: (request: kafka.network.RequestChannel.Request, requestLocal: kafka.server.RequestLocal)Unit.

[2021-06-10T21:42:48.226Z] Unspecified value parameter requestLocal.

@jolshan
Copy link
Member Author

jolshan commented Jun 11, 2021

Ok. This should fix the build. But now it will be a little bit extra work to cherry-pick to 2.8.x 😅

@dengziming
Copy link
Member

Ok. This should fix the build. But now it will be a little bit extra work to cherry-pick to 2.8.x 😅

@jolshan you can open another PR target for 2.8.x if it's difficult to cherry-pick 😂

Copy link
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.

Thanks, a couple more comments below.

Copy link
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.

Thanks, LGTM. Just one nit question below.

@jolshan
Copy link
Member Author

jolshan commented Jun 14, 2021

Ah I see I didn't need that extra declaration but you also removed the comment. Not a huge deal though.

@ijuma
Copy link
Member

ijuma commented Jun 14, 2021

Yeah, that unintentional while using the GitHub editor. Will add it back.

Copy link
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, thanks!

@ijuma ijuma merged commit c16711c into apache:trunk Jun 15, 2021
@ijuma
Copy link
Member

ijuma commented Jun 15, 2021

@jolshan The test needs to be adjusted for 2.8. Can you please look into that? I started on it, but it also needs to handle the fact that an exception is thrown from the handleTopicMetadata method:

  @Test
  def testInvalidMetadataRequestReturnsError(): Unit = {
    // Construct invalid MetadataRequestTopics. We will try each one separately and ensure the error is thrown.
    val topics = List(new MetadataRequestData.MetadataRequestTopic().setName(null).setTopicId(Uuid.randomUuid()),
      new MetadataRequestData.MetadataRequestTopic().setName(null),
      new MetadataRequestData.MetadataRequestTopic().setTopicId(Uuid.randomUuid()),
      new MetadataRequestData.MetadataRequestTopic().setName("topic1").setTopicId(Uuid.randomUuid()))

    // if version is 10 or 11, the invalid topic metadata should return an error
    val invalidVersions = Set(10, 11)
    invalidVersions.foreach( version =>
      topics.foreach(topic => {
        val metadataRequestData = new MetadataRequestData().setTopics(Collections.singletonList(topic))
        val metadataRequest = new MetadataRequest(metadataRequestData, version.toShort)
        val request = buildRequest(metadataRequest)
        val capturedResponse = expectNoThrottling()
        EasyMock.replay(replicaManager, clientRequestQuotaManager,
          autoTopicCreationManager, forwardingManager, clientControllerQuotaManager, groupCoordinator, txnCoordinator)
        createKafkaApis().handleTopicMetadataRequest(request)

        val response = readResponse(metadataRequest, capturedResponse)
          .asInstanceOf[MetadataResponse]
        assertEquals(1, response.topicMetadata.size)
        assertEquals(1, response.errorCounts.get(Errors.INVALID_REQUEST))
        response.data.topics.forEach(topic => assertNotEquals(null, topic.name))
        reset(requestChannel)
      })
    )
  }

jolshan added a commit to jolshan/kafka that referenced this pull request Jun 15, 2021
We prevent handling MetadataRequests where the topic name is null (to prevent NPE) as
well as prevent requests that set topic IDs since this functionality has not yet been
implemented. When we do implement it  in apache#9769,
we should bump the request/response version.

Added tests to ensure the error is thrown.

Reviewers: dengziming <swzmdeng@163.com>, Ismael Juma <ismael@juma.me.uk>
@jolshan
Copy link
Member Author

jolshan commented Jun 15, 2021

I didn't see a branch or PR with the 2.8 version, so I opened my own here: #10885

mjsax added a commit to confluentinc/kafka that referenced this pull request Jun 15, 2021
Resolve merge conflicts in Jenkins file.


* MINOR: clean up unneeded `@SuppressWarnings` (apache#10855)

Reviewers: Luke Chen <showuon@gmail.com>, Matthias J. Sax <mjsax@apache.org>, Chia-Ping Tsai <chia7712@gmail.com>

* KAFKA-12940: Enable JDK 16 builds in Jenkins (apache#10702)

JDK 15 no longer receives updates, so we want to switch from JDK 15 to JDK 16.
However, we have a number of tests that don't yet pass with JDK 16.

Instead of replacing JDK 15 with JDK 16, we have both for now and we either
disable (via annotations) or exclude (via gradle) the tests that don't pass with
JDK 16 yet. The annotations approach is better, but it doesn't work for tests
that rely on the PowerMock JUnit 4 runner.

Also add `--illegal-access=permit` when building with JDK 16 to make MiniKdc
work for now. This has been removed in JDK 17, so we'll have to figure out
another solution when we migrate to that.

Relevant JIRAs for the disabled tests: KAFKA-12790, KAFKA-12941, KAFKA-12942.

Moved some assertions from `testTlsDefaults` to `testUnsupportedTlsVersion`
since the former claims to test the success case while the former tests the failure case.

Reviewers: Chia-Ping Tsai <chia7712@gmail.com>

* KAFKA-12921: Upgrade zstd-jni to 1.5.0-2 (apache#10847)

This PR aims to upgrade `zstd-jni` from `1.4.9-1` to `1.5.0-2`.

This change will incorporate a number of bug fixes and performance improvements made in `1.5.0` of `zstd`:
- https://github.com/facebook/zstd/releases/tag/v1.5.0
- https://github.com/luben/zstd-jni/releases/tag/v1.5.0-1
- https://github.com/luben/zstd-jni/releases/tag/v1.5.0-2

The most recent `1.5.0` release offers +25%-140% (compression) and +15% (decompression) performance
improvements under certain conditions. Those conditions are unlikely to apply to Kafka with the default
configuration, however.

Since this is a dependency change, this should pass all the existing CIs.

Reviewers: Lee Dongjin <dongjin@apache.org>, Ismael Juma <ismael@juma.me.uk>

* KAFKA-8940: decrease session timeout to make test faster and reliable (apache#10871)

While there might still be some issue about the test as described here by @ableegoldman , but I found the reason why this test failed quite frequently recently. It's because we increased the session timeout to 45 sec in KIP-735.

The reason why increasing session timeout affected this test is because in this test, we will keep adding new stream clients and remove old one, to maintain only 3 stream clients alive. The problem here is, when old stream closed, we won't trigger rebalance immediately due to the stream clients are all static members as described in KIP-345, which means, we will trigger trigger group rebalance only when session.timeout expired. That said, when old client closed, we'll have at least 45 sec with some tasks not working.

Also, in this test, we have 2 timeout conditions to fail this test before verification passed:

1. 6 minutes timeout
2. polling 30 times (each with 5 seconds) without getting any data. (that is, 5 * 30 = 150 sec without consuming any data)

For (1), in my test under 45 session timeout, we'll create 8 stream clients, which means, we'll have 5 clients got closed. And each closed client need 45 sec to trigger rebalance, so we'll have 45 * 5 = 225 sec (~4 mins) of the time having some tasks not working.
For (2), during new client created and old client closed, it need some time to do rebalance. With 45 session timeout, we only got ~100 sec left. In slow jenkins env, it might reach the 30 retries without getting any data timeout.

Therefore, decreasing session timeout can make this test completes faster and more reliable.

Reviewers: Guozhang Wang <wangguoz@gmail.com>

* MINOR: enable EOS during smoke test IT (apache#10870)

This IT has been failing on trunk recently. Enabling EOS during the integration test
makes it easier to be sure that the test's assumptions are really true during verification
and should make the test more reliable.

I also noticed that in the actual system test file, we are using the deprecated property
name "beta" instead of "v2".

Reviewers: Boyang Chen <boyang@apache.org>

* MINOR: Log formatting for exceptions during configuration related operations (apache#10843)

Format configuration logging during exceptions or errors. Also make sure it redacts sensitive information or unknown values.

Reviewers: Luke Chen <showuon@gmail.com>, David Jacot <djacot@confluent.io>

* KAFKA-12914: StreamSourceNode should return `null` topic name for pattern subscription (apache#10846)

Reviewers: Luke Chen <showuon@gmail.com>, Bruno Cadonna <bruno@confluent.io>, Guozhang Wang <guozhang@confluent.io>

* KAFKA-12948: Remove node from ClusterConnectionStates.connectingNodes when node is removed (apache#10882)

NetworkClient.poll() throws IllegalStateException when checking isConnectionSetupTimeout if all nodes in ClusterConnectionStates.connectingNodes aren't present in ClusterConnectionStates.nodeState. This commit ensures that when we remove a node from nodeState, we also remove from connectingNodes.

Reviewers: David Jacot <djacot@confluent.io>

* KAFKA-12701: NPE in MetadataRequest when using topic IDs (apache#10584)

We prevent handling MetadataRequests where the topic name is null (to prevent NPE) as
well as prevent requests that set topic IDs since this functionality has not yet been
implemented. When we do implement it  in apache#9769,
we should bump the request/response version.

Added tests to ensure the error is thrown.

Reviewers: dengziming <swzmdeng@163.com>, Ismael Juma <ismael@juma.me.uk>

Co-authored-by: Josep Prat <josep.prat@aiven.io>
Co-authored-by: Ismael Juma <ismael@juma.me.uk>
Co-authored-by: David Christle <dchristle@users.noreply.github.com>
Co-authored-by: Luke Chen <showuon@gmail.com>
Co-authored-by: John Roesler <vvcephei@users.noreply.github.com>
Co-authored-by: YiDing-Duke <dingyi.zj@gmail.com>
Co-authored-by: Rajini Sivaram <rajinisivaram@googlemail.com>
Co-authored-by: Justine Olshan <jolshan@confluent.io>
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.

3 participants

Comments