ocadaruma commented on code in PR #12405: URL: https://github.com/apache/kafka/pull/12405#discussion_r922801263
########## core/src/main/scala/kafka/controller/ControllerContext.scala: ########## @@ -328,8 +328,9 @@ class ControllerContext { } def queueTopicDeletion(topics: Set[String]): Unit = { + val newlyDeletedTopics = topics.diff(topicsToBeDeleted) Review Comment: (I'm not 100% sure if I get your concern. If my answer doesn't make sense, please tell me) In the first place, the purpose of `cleanPreferredReplicaImbalanceMetric` is to "unmark" partitions which has imbalanced leader. So, below is the expected behavior (let's say topic-A has single partition): - Initiate topic-A deletion - If topic-A-0 has imbalanced leader (e.g. lost leadership once, replica-reassignment, became offline etc) here, `preferredReplicaImbalanceCount` contains the count for it here, so we have to decrement it because the partition is to be deleted * `!hasPreferredLeader` evaluates to true so decremented as expected - Otherwise, we don't have to decrement the value because `preferredReplicaImbalanceCount` doesn't contain the imbalance count for `topic-A-0`. "A partition should be decremented from preferredReplicaImbalanceCount on topic-deletion only if the partition is actually imbalanced at the topic-deletion timing" is the invariant that topic-deletion procedure must satisfy. So, essentially, the problem is that topic-A-0 could be marked as "imbalanced" wrongly when it becomes offline during deletion-procedure. > So, what if the topic-A haven't reached this condition and we entering cleanPreferredReplicaImbalanceMetric? Will that cause some partitions count should be decremented but they are not? "topic-A haven't reached this condition" means the partition wasn't imbalanced actually, so we do not have to decrement the count. -- 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