Chia-Ping Tsai created KAFKA-20347:
--------------------------------------

             Summary: Fix metric leak and JMX tag order in 
ShareCoordinatorMetrics
                 Key: KAFKA-20347
                 URL: https://issues.apache.org/jira/browse/KAFKA-20347
             Project: Kafka
          Issue Type: Bug
            Reporter: Chia-Ping Tsai
            Assignee: Chia-Ping Tsai


{code:java}
Map<String, String> tags = Map.of(
    "topic", tp.topic(),
    "partition", Integer.toString(tp.partition())
); {code}
the order of `Map.of` is undefined, so the generated JMX metric names are 
unpredictable


{code:java}
public void deactivateMetricsShard(CoordinatorMetricsShard shard) {
    if (!(shard instanceof ShareCoordinatorMetricsShard)) {
        throw new IllegalArgumentException("ShareCoordinatorMetrics can only 
deactivate ShareCoordinatorMetricShard");
    }
    shards.remove(shard.topicPartition());
    ShareGroupPruneMetrics removed = 
pruneMetrics.remove(shard.topicPartition());
    if (removed != null) {
        metrics.removeSensor(removed.pruneSensor.name());
    }
} {code}
we forgot to remove the sensor when the partition leader gets changed.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to