You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by "Sumit Agrawal (Jira)" <ji...@apache.org> on 2026/06/04 02:16:00 UTC
[jira] [Created] (HDDS-15475) containerMap is not threadsafe
Sumit Agrawal created HDDS-15475:
------------------------------------
Summary: 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
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: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org