HDFS-16939. Fix the thread safety bug in LowRedundancyBlocks. (#5450). Contributed by Shuyan Zhang.
Signed-off-by: He Xiaoqiao <hexiaoqiao@apache.org>
This commit is contained in:
parent
2a0dc2ab2f
commit
2cb0c35fc1
|
@ -86,10 +86,10 @@ class LowRedundancyBlocks implements Iterable<BlockInfo> {
|
|||
private final List<LightWeightLinkedSet<BlockInfo>> priorityQueues
|
||||
= new ArrayList<>(LEVEL);
|
||||
|
||||
/** The number of corrupt blocks with replication factor 1 */
|
||||
|
||||
private final LongAdder lowRedundancyBlocks = new LongAdder();
|
||||
private final LongAdder corruptBlocks = new LongAdder();
|
||||
/** The number of corrupt blocks with replication factor 1 */
|
||||
private final LongAdder corruptReplicationOneBlocks = new LongAdder();
|
||||
private final LongAdder lowRedundancyECBlockGroups = new LongAdder();
|
||||
private final LongAdder corruptECBlockGroups = new LongAdder();
|
||||
|
@ -369,11 +369,11 @@ class LowRedundancyBlocks implements Iterable<BlockInfo> {
|
|||
* @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) {
|
||||
return remove(block, priLevel, block.getReplication());
|
||||
}
|
||||
|
||||
boolean remove(BlockInfo block, int priLevel, int oldExpectedReplicas) {
|
||||
synchronized boolean remove(BlockInfo block, int priLevel, int oldExpectedReplicas) {
|
||||
if(priLevel >= 0 && priLevel < LEVEL
|
||||
&& priorityQueues.get(priLevel).remove(block)) {
|
||||
NameNode.blockStateChangeLog.debug(
|
||||
|
|
Loading…
Reference in New Issue