[
https://issues.apache.org/jira/browse/HDDS-15475?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Tsz-wo Sze reassigned HDDS-15475:
---------------------------------
Assignee: Tsz-wo Sze
> containerMap is not threadsafe
> ------------------------------
>
> Key: HDDS-15475
> URL: https://issues.apache.org/jira/browse/HDDS-15475
> Project: Apache Ozone
> Issue Type: Bug
> Components: SCM
> Reporter: Sumit Agrawal
> Assignee: Tsz-wo Sze
> Priority: Major
>
> As part of fix, *HDDS-12555.* *Combine containerMap and replicaMap in
> ContainerStateMap ,* containerMap as updated combining is not threadsafe.
>
> *Issue as code review:* concurrency issue as below: * {*}Earlier{*},
> containerMap and replicaMap are ConcurrentHashMap as thread Safe
> * {*}Now{*}, containerMap which have map as TreeMap which is *not* Thread
> safe
> *They are accessed with 2 different lock be caller,* # {{*lock*}} Object for
> add/remove container as global lock
> # {{stripedLock}} for container update and access at *container level* lock
> with container ID, Above lock is not taken.
> So, *Update* is happening with *different lock* and *Read* is happening with
> {*}another lock{*}. This can cause crash as thread safe is no maintained.
>
> As solution,
> 1. make TreeMap thread safe and all internal map as Synchronized Wrapper
> like Collections.synchronizedSortedMap(new TreeMap<>());
> But tailMap iterator is not threadsafe. So better to use
> {*}ConcurrentSkipListMap{*}<>
>
> 2. OR Rollback combine both map and let be ConcurrentHashMap if above change
> does not have any performance improvement.
>
> cc: [~szetszwo]
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]