showuon commented on code in PR #15133:
URL: https://github.com/apache/kafka/pull/15133#discussion_r1461855180


##########
core/src/main/java/kafka/log/remote/RemoteLogManager.java:
##########
@@ -1650,15 +1650,27 @@ private static void 
shutdownAndAwaitTermination(ExecutorService pool, String poo
     }
 
     private void removeRemoteTopicPartitionMetrics(TopicIdPartition 
topicIdPartition) {
-        BrokerTopicMetrics topicMetrics = 
brokerTopicStats.topicStats(topicIdPartition.topic());
-        int partition = topicIdPartition.partition();
-        topicMetrics.removeRemoteCopyLagBytes(partition);
-        topicMetrics.removeRemoteCopyLagSegments(partition);
-        topicMetrics.removeRemoteDeleteLagBytes(partition);
-        topicMetrics.removeRemoteDeleteLagSegments(partition);
-        topicMetrics.removeRemoteLogMetadataCount(partition);
-        topicMetrics.removeRemoteLogSizeComputationTime(partition);
-        topicMetrics.removeRemoteLogSizeBytes(partition);
+        String topic = topicIdPartition.topic();
+        if (!brokerTopicStats.isTopicStatsExisted(topicIdPartition.topic())) {
+            // The topic metrics are already removed, removing this topic key 
from broker-level metrics
+            brokerTopicStats.removeBrokerLevelRemoteCopyLagBytes(topic);

Review Comment:
   When topic deleted, replicaManager will remove all metrics for the topic. 
All we need to do is to update  the allTopics metrics value by removing the 
topic key from the internal map



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