mjsax commented on code in PR #20326:
URL: https://github.com/apache/kafka/pull/20326#discussion_r2544167851
##########
streams/src/main/java/org/apache/kafka/streams/processor/internals/InternalTopicManager.java:
##########
@@ -480,6 +482,11 @@ public Set<String> makeReady(final Map<String,
InternalTopicConfig> topics) {
.filter(e -> topicsNotReady.contains(e.getKey()))
.collect(Collectors.toMap(Map.Entry::getKey,
Map.Entry::getValue));
final Set<NewTopic> topicsToCreate =
computeTopicsToCreate(notReadyTopicsMap, tempUnknownTopics);
+
+ topicsNotReady.retainAll(tempUnknownTopics);
+ topicsNotReady.retainAll(notReadyTopicsMap.keySet());
+ topicsToCreate.forEach(topic -> topicsNotReady.add(topic.name()));
Review Comment:
This seems to be unnecessarily complex? We first remove topics, and in the
third line add back topics... So it seem we are removing topic we should not
have remove, just to add them back?
In the end, we should only remove the topics from `topicNotReady` which do
already exist.
The issue seems to be, that we want to retain both `tempUnknownTopics` and
`notReadyTopicsMap.keySet()`, but calling `retainAll` twice does not do this,
but we would need a call `topicsNotReady.retainAll(union(tempUnknownTopics,
notReadyTopicsMap.keySet()))`?
Or we rewrite this using `removeIf` instead of the three lines you added (I
believe [but not 100% sure] this line would do the trick?
```
topicsNotReady.removeIf(t -> !topicsToCreate.contains(t) &&
!tempUnknownTopics.contains(t));
```
Or maybe my original comment could help (or would this not work?)
https://github.com/apache/kafka/pull/20326#discussion_r2512435233
I think, if we modify `topicsNotReady` there (ie, `topicMap` which is the
corresponding parameter name inside the `computeTopicsToCreate` for which we
pass in `topicsNotReady`), it should fix it, allowing us to avoid the code
complexity here?
##########
streams/src/main/java/org/apache/kafka/streams/processor/internals/InternalTopicManager.java:
##########
@@ -421,9 +426,11 @@ public Map<String, List<TopicPartitionInfo>>
getTopicPartitionInfo(final Set<Str
final Map<String, List<TopicPartitionInfo>> topicPartitionInfo = new
HashMap<>();
while (!topicsToDescribe.isEmpty()) {
- final Map<String, List<TopicPartitionInfo>> existed =
getTopicPartitionInfo(topicsToDescribe, null);
+ final Set<String> tempUnknownTopics = new HashSet<>();
+ final Map<String, List<TopicPartitionInfo>> existed =
getTopicPartitionInfo(topicsToDescribe, tempUnknownTopics);
topicPartitionInfo.putAll(existed);
topicsToDescribe.removeAll(topicPartitionInfo.keySet());
+ topicsToDescribe.addAll(tempUnknownTopics); // keep retrying
unknown ones
Review Comment:
It's not clear to me, why we need this change and keep retrying?
--
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]