sodonnel commented on code in PR #3909:
URL: https://github.com/apache/ozone/pull/3909#discussion_r1010730408
##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/replication/ContainerReplicaPendingOps.java:
##########
@@ -47,6 +49,9 @@ public class ContainerReplicaPendingOps {
private final ConcurrentHashMap<ContainerID, List<ContainerReplicaOp>>
pendingOps = new ConcurrentHashMap<>();
private final Striped<ReadWriteLock> stripedLock = Striped.readWriteLock(64);
+ private Map<ContainerReplicaOp.PendingOpType, Long>
+ pendingOpCount = new HashMap<>();
Review Comment:
I think this map could be updated concurrently. The lock in this class is a
striped lock, so it is possible for multiple "add" or "complete" calls to run
concurrently provided they are against different containerIDs.
The PendingOps may is a ConcurrentHashMap for this reason, but even if
pendingOpCount was a ConcurrentHashMap, I think the counter saved against the
key could suffer from lost updates.
If you pre-populate pendingOps with all the available opTypes, so the map is
baiscally readonly, and make the value be an atomicLong, rather than a long, I
think it would avoid any problems.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]