ChoMinGi opened a new pull request, #23180:
URL: https://github.com/apache/kafka/pull/23180

   StreamsMetricsImpl records the names of sensors created through its
   level-specific APIs in per-level collections so that the sensors can be 
removed
   later. A name is recorded only when metrics.getSensor(fullSensorName) returns
   null, but removeSensor(Sensor) drops the sensor from the registry without
   removing its name from the collection, so a sensor that is removed and
   recreated has its name recorded once per cycle. RecordQueue#close(),
   RecordCollectorImpl#removeAllProducedSensors(), and
   DefaultStateUpdater.StateUpdaterMetrics#clear() remove sensors through this
   path. The sensors and their metrics are removed correctly; only duplicate
   bookkeeping entries accumulate.
   
   This changes those collections to use Set so that each name is recorded at 
most
   once. The removal order is not semantically significant because
   Metrics#removeSensor is idempotent and removes child sensors recursively;
   LinkedHashSet avoids hash-order-dependent teardown.
   removeAllClientLevelSensors() takes a snapshot of the names before removing 
the
   sensors, so the collection is not iterated while removal runs.
   
   The two added tests repeatedly create and remove the same topic-level sensor 
and
   the same client-level sensor, and assert that each name is retained once. 
Both
   tests fail without this change.
   


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

Reply via email to