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

ASF GitHub Bot commented on HDFS-16939:
---------------------------------------

saxenapranav commented on code in PR #5450:
URL: https://github.com/apache/hadoop/pull/5450#discussion_r1124561712


##########
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/LowRedundancyBlocks.java:
##########
@@ -369,7 +369,7 @@ synchronized boolean remove(BlockInfo block,
    * @return true if the block was found and removed from one of the priority
    *         queues
    */
-  boolean remove(BlockInfo block, int priLevel) {
+  synchronized boolean remove(BlockInfo block, int priLevel) {

Review Comment:
   > > should `boolean remove(BlockInfo block, int priLevel, int 
oldExpectedReplicas)` be made synchronized instead. Its other callers are 
synchronized methods:
   > 
   > Sorry I don't quite understand. Since the callers are already 
synchronized, why is it necessary to made `boolean remove(BlockInfo block, int 
priLevel, int oldExpectedReplicas)` synchronized?
   
   Since  `boolean remove(BlockInfo block, int priLevel)` forwards the call to 
`boolean remove(BlockInfo block, int priLevel, int oldExpectedReplicas)`, I am 
suggesting that lets make `boolean remove(BlockInfo block, int priLevel, int 
oldExpectedReplicas)` synchronized instead.
   Callers of `boolean remove(BlockInfo block, int priLevel, int 
oldExpectedReplicas)` are synchronized means that we can have `boolean 
remove(BlockInfo block, int priLevel, int oldExpectedReplicas)` as synchronized 
without any perf-loss.





> Fix the thread safety bug in LowRedundancyBlocks
> ------------------------------------------------
>
>                 Key: HDFS-16939
>                 URL: https://issues.apache.org/jira/browse/HDFS-16939
>             Project: Hadoop HDFS
>          Issue Type: Bug
>          Components: namanode
>            Reporter: Shuyan Zhang
>            Assignee: Shuyan Zhang
>            Priority: Major
>              Labels: pull-request-available
>
> The remove method in LowRedundancyBlocks is not protected by synchronized. 
> This method is private and is called by BlockManager. As a result, 
> priorityQueues has the risk of being accessed concurrently by multiple 
> threads.



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

---------------------------------------------------------------------
To unsubscribe, e-mail: hdfs-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: hdfs-issues-h...@hadoop.apache.org

Reply via email to