You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ratis.apache.org by "Lokesh Jain (Jira)" <ji...@apache.org> on 2020/04/21 10:12:00 UTC

[jira] [Commented] (RATIS-857) Thread unsafe RaftServerMetrics::metricsMap HashMap in multi thread

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

Lokesh Jain commented on RATIS-857:
-----------------------------------

[~yjxxtd] Thanks for working on this! The changes look good to me. +1.

> Thread unsafe RaftServerMetrics::metricsMap HashMap in multi thread
> -------------------------------------------------------------------
>
>                 Key: RATIS-857
>                 URL: https://issues.apache.org/jira/browse/RATIS-857
>             Project: Ratis
>          Issue Type: Bug
>          Components: metrics
>            Reporter: runzhiwang
>            Assignee: runzhiwang
>            Priority: Major
>         Attachments: RATIS-857.001.patch
>
>
> *What's the problem ?*
> The {color:#DE350B}static{color} variable [RaftServerMetrics::metricsMap|https://github.com/apache/incubator-ratis/blob/master/ratis-server/src/main/java/org/apache/ratis/server/impl/RaftServerMetrics.java#L71] is type of HashMap, which is not thread safe. But entry will be [put|https://github.com/apache/incubator-ratis/blob/master/ratis-server/src/main/java/org/apache/ratis/server/impl/RaftServerMetrics.java#L76] into metricsMap by different thread, when create each RaftServerImpl instance.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)