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#1030
Merged
anuengineer merged 1 commit intoapache:trunkfrom Jun 28, 2019
Conversation
…ted by synchronization on itself. However, in one place, the field is inside a synchronized on a different object, which does not ensure protection.
|
💔 -1 overall
This message was automatically generated. |
shanthoosh
added a commit
to shanthoosh/hadoop
that referenced
this pull request
Oct 15, 2019
…e#1030) * Adding initial implementation for EventHubSystemAdmin. * Code clean up.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The field
timedOutItems(anArrayList, 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 protecttimedOutItems.Synchronized on different objects does not ensure mutual exclusion with the other locations.
I.e., 2 code locations, one synchronized by
pendingReconstructionsand the other bytimedOutItemscan 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 (protectpendingReconstructions)