You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-issues@hadoop.apache.org by GitBox <gi...@apache.org> on 2019/06/28 18:41:58 UTC

[GitHub] [hadoop] paulward24 opened a new pull request #1030: ArrayList is not thread safe. Field timedOutItems is typically protected by synchronization on itself. However, in one place, the field is inside a synchronized on a different object, which does not ensure protection

paulward24 opened a new pull request #1030: ArrayList is not thread safe. Field timedOutItems is typically protected by synchronization on itself. However, in one place, the field is inside a synchronized on a different object, which does not ensure protection
URL: https://github.com/apache/hadoop/pull/1030
 
 
   The field ```timedOutItems```  (an ```ArrayList```, i.e., not thread safe):
   
   https://github.com/apache/hadoop/blob/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/PendingReconstructionBlocks.java#L70
   
   is protected by synchronization on itself (```timedOutItems```):
   
   https://github.com/apache/hadoop/blob/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/PendingReconstructionBlocks.java#L167-L168
   
   https://github.com/apache/hadoop/blob/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/PendingReconstructionBlocks.java#L267-L268
   
   https://github.com/apache/hadoop/blob/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/PendingReconstructionBlocks.java#L178
   
   However, in one place:
   
   https://github.com/apache/hadoop/blob/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/PendingReconstructionBlocks.java#L133-L135
   
   it is (trying to be) protected by synchronized using ```pendingReconstructions``` --- but this cannot protect ```timedOutItems```.
   
   Synchronized on different objects does not ensure mutual exclusion with the other locations.
   
   I.e., 2 code locations, one synchronized by ```pendingReconstructions``` and the other by ```timedOutItems``` can still executed concurrently.
   
   
   This CR adds the synchronized on ```timedOutItems```.
   
   Note that this CR keeps the synchronized on ```pendingReconstructions```, which is needed for a different purpose (protect ```pendingReconstructions```)
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-issues-help@hadoop.apache.org