dajac commented on code in PR #14327:
URL: https://github.com/apache/kafka/pull/14327#discussion_r1469602233


##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:
##########
@@ -1573,6 +1589,33 @@ private void updateGroupsByTopics(
                 }
             });
         }
+        if (!oldSubscribedTopicRegex.isEmpty()) {
+            oldSubscribedTopicRegex.forEach(regex -> {
+                groupsByRegex.computeIfPresent(regex, (__, groupIds) -> {
+                    groupIds.remove(groupId);
+                    return groupIds.isEmpty() ? null : groupIds;
+                });
+                Pattern pattern = Pattern.compile(regex);
+                for (String topicName : 
metadataImage.topics().topicsByName().keySet()) {
+                    if (pattern.matcher(topicName).matches()) {
+                        unsubscribeGroupFromTopic(groupId, topicName);
+                    }
+                }
+            });
+        }
+        if (!newSubscribedTopicRegex.isEmpty()) {
+            newSubscribedTopicRegex.forEach(regex -> {
+                groupsByRegex
+                        .computeIfAbsent(regex, __ -> new 
TimelineHashSet<>(snapshotRegistry, 1))
+                        .add(groupId);
+                Pattern pattern = Pattern.compile(regex);
+                for (String topicName : 
metadataImage.topics().topicsByName().keySet()) {
+                    if (pattern.matcher(topicName).matches()) {
+                        subscribeGroupToTopic(groupId, topicName);
+                    }
+                }

Review Comment:
   @Phuc-Hong-Tran It is definitely expensive wherever it will be :). The major 
downside of doing it here is that when you reload the group coordinator state 
from the partition, you may have obsolete records containing regex which are 
not compacted yet. For those, we would compute the list for nothing.



-- 
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