FrankYang0529 commented on code in PR #19761:
URL: https://github.com/apache/kafka/pull/19761#discussion_r2107213749


##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/Utils.java:
##########
@@ -349,12 +349,19 @@ static void throwIfRegularExpressionIsInvalid(
      * @return The hash of the group.
      */
     static long computeGroupHash(Map<String, Long> topicHashes) {
-        if (topicHashes.isEmpty()) {
+        // Sort entries by topic name
+        List<Map.Entry<String, Long>> sortedEntries = new ArrayList<>();
+        for (Map.Entry<String, Long> entry : topicHashes.entrySet()) {
+            // Filter out entries with a hash value of 0, which indicates no 
topic
+            if (entry.getValue() != 0) {

Review Comment:
   We use `computeSubscribedTopicNames` to get `subscribedTopicNames` and use 
the result to calculate topic hashes which group wants to subscribe to.  
However, the `computeSubscribedTopicNames` doesn't check whether a topic is 
really existent. If a group subscribes to a non-existent topic, the topic is in 
`subscribedTopicNames` and the `computeMetadataHash` uses non-existent topic 
hash as part of metadata hash.
   
   A sample case is `testSubscriptionMetadataRefreshedAgainAfterWriteFailure`.  
The group subscribes to `foo` and `bar`, but `bar` topic is not in metadata 
image.
   
   
https://github.com/apache/kafka/blob/48a52701b9cd45c4854f910990a85be7d73e22f5/group-coordinator/src/main/java/org/apache/kafka/coordinator/group/modern/ModernGroup.java#L496-L507



-- 
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-unsubscr...@kafka.apache.org

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

Reply via email to