You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "splett2 (via GitHub)" <gi...@apache.org> on 2023/11/02 22:00:26 UTC

[PR] KAFKA-15780: Wait for consistent KRaft metadata when creating topics [kafka]

splett2 opened a new pull request, #14695:
URL: https://github.com/apache/kafka/pull/14695

   ### What
   TestUtils.createTopicWithAdmin calls `waitForAllPartitionsMetadata` which waits for partition(s) to be present in each brokers' metadata cache. This is a sufficient check in ZK mode because the controller sends an LISR request before sending an UpdateMetadataRequest which means that the partition in the `ReplicaManager` will be updated before the metadata cache.
   
   In KRaft mode, the metadata cache is updated first, so the check may return before partitions and other metadata listeners are fully initialized.
   
   ### Testing
   Insert a `Thread.sleep(100)` in `BrokerMetadataPublisher.onMetadataUpdate` after 
   ```
         // Publish the new metadata image to the metadata cache.
         metadataCache.setImage(newImage)
   ```
   and run `EdgeCaseRequestTest.testProduceRequestWithNullClientId` and the test will fail locally nearly deterministically. After the change(s), the test no longer fails.
   
   ### Committer Checklist (excluded from commit message)
   - [ ] Verify design and implementation 
   - [ ] Verify test coverage and CI build status
   - [ ] Verify documentation (including upgrade notes)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KAFKA-15780: Wait for consistent KRaft metadata when creating or deleting topics [kafka]

Posted by "splett2 (via GitHub)" <gi...@apache.org>.
splett2 commented on PR #14695:
URL: https://github.com/apache/kafka/pull/14695#issuecomment-1793078392

   @jolshan 
   that's right.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KAFKA-15780: Wait for consistent KRaft metadata when creating or deleting topics [kafka]

Posted by "jolshan (via GitHub)" <gi...@apache.org>.
jolshan commented on code in PR #14695:
URL: https://github.com/apache/kafka/pull/14695#discussion_r1383784448


##########
core/src/test/scala/unit/kafka/integration/KafkaServerTestHarness.scala:
##########
@@ -178,6 +178,7 @@ abstract class KafkaServerTestHarness extends QuorumTestHarness {
           admin = admin,
           topic = topic,
           brokers = brokers,
+          controllerServers,

Review Comment:
   nit :) 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KAFKA-15780: Wait for consistent KRaft metadata when creating or deleting topics [kafka]

Posted by "jolshan (via GitHub)" <gi...@apache.org>.
jolshan commented on code in PR #14695:
URL: https://github.com/apache/kafka/pull/14695#discussion_r1381974229


##########
core/src/test/scala/unit/kafka/server/GroupCoordinatorBaseRequestTest.scala:
##########
@@ -44,10 +44,19 @@ class GroupCoordinatorBaseRequestTest(cluster: ClusterInstance) {
     }
   }
 
+  private def controllerServers(): Seq[ControllerServer] = {
+    if (cluster.isKRaftTest) {
+      cluster.asInstanceOf[RaftClusterInstance].controllers().collect(Collectors.toList[ControllerServer]).asScala.toSeq
+    } else {
+      Seq.empty
+    }
+  }
+
   protected def createOffsetsTopic(): Unit = {
     TestUtils.createOffsetsTopicWithAdmin(
       admin = cluster.createAdminClient(),
-      brokers = brokers()
+      brokers = brokers(),
+      controllerServers()

Review Comment:
   did we want to saw `controllers = controllerServers()` here for consistency?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KAFKA-15780: Wait for consistent KRaft metadata when creating or deleting topics [kafka]

Posted by "jolshan (via GitHub)" <gi...@apache.org>.
jolshan commented on PR #14695:
URL: https://github.com/apache/kafka/pull/14695#issuecomment-1792813212

   To clarify -- this works because controllerServers() in QuorumTestHarness returns an empty list for Zk clusters?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KAFKA-15780: Wait for consistent KRaft metadata when creating or deleting topics [kafka]

Posted by "jolshan (via GitHub)" <gi...@apache.org>.
jolshan commented on PR #14695:
URL: https://github.com/apache/kafka/pull/14695#issuecomment-1797110144

   Took a look at the failures and they look unrelated. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KAFKA-15780: Wait for consistent KRaft metadata when creating or deleting topics [kafka]

Posted by "jolshan (via GitHub)" <gi...@apache.org>.
jolshan merged PR #14695:
URL: https://github.com/apache/kafka/pull/14695


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KAFKA-15780: Wait for consistent KRaft metadata when creating or deleting topics [kafka]

Posted by "jolshan (via GitHub)" <gi...@apache.org>.
jolshan commented on PR #14695:
URL: https://github.com/apache/kafka/pull/14695#issuecomment-1799528544

   I can do that if we think it is useful.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KAFKA-15780: Wait for consistent KRaft metadata when creating or deleting topics [kafka]

Posted by "jolshan (via GitHub)" <gi...@apache.org>.
jolshan commented on code in PR #14695:
URL: https://github.com/apache/kafka/pull/14695#discussion_r1381978740


##########
core/src/test/scala/unit/kafka/server/GroupCoordinatorBaseRequestTest.scala:
##########
@@ -44,10 +44,19 @@ class GroupCoordinatorBaseRequestTest(cluster: ClusterInstance) {
     }
   }
 
+  private def controllerServers(): Seq[ControllerServer] = {
+    if (cluster.isKRaftTest) {
+      cluster.asInstanceOf[RaftClusterInstance].controllers().collect(Collectors.toList[ControllerServer]).asScala.toSeq

Review Comment:
   could we just use controllerServers here?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KAFKA-15780: Wait for consistent KRaft metadata when creating or deleting topics [kafka]

Posted by "divijvaidya (via GitHub)" <gi...@apache.org>.
divijvaidya commented on PR #14695:
URL: https://github.com/apache/kafka/pull/14695#issuecomment-1798003212

   @jolshan @splett2 are we planning this to backport to 3.6 & 3.5 as well? This will help stabilize tests during version release for 3.5.2 and 3.6.1.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org