You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ratis.apache.org by "Duong (Jira)" <ji...@apache.org> on 2024/05/28 19:32:00 UTC

[jira] [Resolved] (RATIS-2063) Unclosed SegmentedRaftLogMetrics causes memory leaks.

     [ https://issues.apache.org/jira/browse/RATIS-2063?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Duong resolved RATIS-2063.
--------------------------
    Resolution: Not A Problem

> Unclosed SegmentedRaftLogMetrics causes memory leaks.
> -----------------------------------------------------
>
>                 Key: RATIS-2063
>                 URL: https://issues.apache.org/jira/browse/RATIS-2063
>             Project: Ratis
>          Issue Type: Improvement
>            Reporter: Duong
>            Priority: Major
>
> [SegmentedRaftLogMetrics|https://github.com/duongkame/ratis/blob/master/ratis-server/src/main/java/org/apache/ratis/server/raftlog/segmented/SegmentedRaftLog.java#L212-L212] is not unregistered when RaftServer is closed. This causes the leak of many objects that SegmentedRaftLogMetrics refers to indirectly via a metric register, for example, SegmentedRaftLog:
> {code:java}
>   SegmentedRaftLogWorker(RaftGroupMemberId memberId, StateMachine stateMachine, Runnable submitUpdateCommitEvent,
>                          RaftServer.Division server, RaftStorage storage, RaftProperties properties,
>                          SegmentedRaftLogMetrics metricRegistry) {
>     metricRegistry.addDataQueueSizeGauge(queue::getNumElements);
>     metricRegistry.addLogWorkerQueueSizeGauge(writeTasks.q::size);
>     metricRegistry.addFlushBatchSizeGauge(() -> flushBatchSize);
> }
> {code}
> In the above code, MetricRegistry will keep references to the lamda objects which in turn refer to the SegmentedRaftLogWorker object itself. 
> The metricRegistry in SegmentedRaftLogMetrics must be unregistered when RaftServer is close to allowing GC to collect all discarded objects.



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