AndrewJSchofield commented on code in PR #24115: URL: https://github.com/apache/kafka/pull/24115#discussion_r4499295934
########## gradle/spotbugs-exclude.xml: ########## @@ -730,14 +730,23 @@ For a detailed description of spotbugs bug categories, see https://spotbugs.read </Match> <Match> - <!-- AdminMetadataManager's lastMetadataFetchAttemptMs and lastMetadataUpdateMs are only - written from the AdminClient I/O thread, so non-atomic 64-bit writes are safe. --> + <!-- AdminMetadataManager's lastMetadataFetchAttemptMs, lastMetadataUpdateMs and equivalentResponseCount + are only written from the AdminClient I/O thread, so non-atomic 64-bit writes are safe. --> <Class name="org.apache.kafka.clients.admin.internals.AdminMetadataManager"/> Review Comment: Hmm. I would prefer to have these small concurrency issues fixed rather than extend the scope of the findbugs exclusions. ########## clients/src/main/java/org/apache/kafka/clients/admin/internals/AdminMetadataManager.java: ########## Review Comment: The equivalent method in `Metadata` has an extra parameter so that the equivalent response count can be reset when the caller deems it appropriate. It's good that this PR introduces the same equivalent response count concept, but I think that it is probably appropriate to have the same mechanism to reset the equivalent response count. I think that `clearController` should probably reset the equivalent response count, for example. ########## clients/src/main/java/org/apache/kafka/clients/admin/internals/AdminMetadataManager.java: ########## @@ -354,6 +371,14 @@ public void update(Cluster cluster, long now) { bootstrapCluster = cluster; } else { log.debug("Updating cluster metadata to {}", cluster); + // A response is equivalent if it has the same nodes as the previous one and that one has not expired. + // The controller is not compared because brokers return a random alive broker as the controller. + if (now - lastMetadataUpdateMs < metadataExpireMs && + new HashSet<>(cluster.nodes()).equals(new HashSet<>(this.cluster.nodes()))) { Review Comment: This double-allocation seems excessive. -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
