[ 
https://issues.apache.org/jira/browse/FLINK-28852?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17590109#comment-17590109
 ] 

chenyuzhi edited comment on FLINK-28852 at 8/31/22 8:23 AM:
------------------------------------------------------------

I'd like to take this ticket!

 

I think the problem comes from *MetricStore.class,* beause it always add 
metrics but  not clear them when refreshing to query metrics . As the code 
shown below:
{code:java}
synchronized void addAll(List<MetricDump> metricDumps) {
    for (MetricDump metric : metricDumps) {
        add(metric);
    }
}
{code}
If we can clear the previous metrics before adding the latest metrics ,the 
problem could be solved.

 

I am planning to add a method named  *clearMetrics* which could be implemented 
by  {*}ComponentMetricStore/JobMetricStore/TaskMetricStore{*}, and then we 
could change the code above to:
{code:java}
synchronized void addAll(List<MetricDump> metricDumps) {
    jobManager.clearMetrics();
    taskManagers.values().forEach(ComponentMetricStore::clearMetrics);
    jobs.values().forEach(JobMetricStore::clearMetrics);
    for (MetricDump metric : metricDumps) {
        add(metric);
    }
} {code}
I had tested the changed code in our unit test and flink cluster.

 

 


was (Author: stupid_pig):
I think the problem comes from *MetricStore.class,* beause it always add 
metrics but  not clear them when refreshing to query metrics . As the code 
shown below:
{code:java}
synchronized void addAll(List<MetricDump> metricDumps) {
    for (MetricDump metric : metricDumps) {
        add(metric);
    }
}
{code}
If we can clear the previous metrics before adding the latest metrics ,the 
problem could be solved.

 

I am planning to add a method named  *clearMetrics* which could be implemented 
by  {*}ComponentMetricStore/JobMetricStore/TaskMetricStore{*}, and then we 
could change the code above to:
{code:java}
synchronized void addAll(List<MetricDump> metricDumps) {
    jobManager.clearMetrics();
    taskManagers.values().forEach(ComponentMetricStore::clearMetrics);
    jobs.values().forEach(JobMetricStore::clearMetrics);
    for (MetricDump metric : metricDumps) {
        add(metric);
    }
} {code}
I had tested the changed code in our unit test and flink cluster.

Thus, I'd like to take this ticket!

 

> Closed metrics could be found in metric dashboard from WebUI
> ------------------------------------------------------------
>
>                 Key: FLINK-28852
>                 URL: https://issues.apache.org/jira/browse/FLINK-28852
>             Project: Flink
>          Issue Type: Bug
>          Components: Runtime / Metrics
>         Environment: Flink 1.11.3
>            Reporter: chenyuzhi
>            Priority: Major
>
> When I close  metric group, the related metrics would be unregistered from 
> metric-reporter, however the closed metrics could be found in metric dashboad 
> from WebUI.
> This would leak to memory leak.



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

Reply via email to