From f4ba5ff1d70ef92d59851c09c4bd4b43d6c04971 Mon Sep 17 00:00:00 2001 From: Jing Zhao Date: Wed, 3 Aug 2016 11:39:06 -0700 Subject: [PATCH] HDFS-10710. In BlockManager#rescanPostponedMisreplicatedBlocks(), postponed misreplicated block counts should be retrieved within the NN lock protection.Contributed by GAO Rui. --- .../hadoop/hdfs/server/blockmanagement/BlockManager.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockManager.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockManager.java index 349b018505f..6c25d6414d3 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockManager.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockManager.java @@ -2278,9 +2278,9 @@ public class BlockManager implements BlockStatsMXBean { return; } long startTimeRescanPostponedMisReplicatedBlocks = Time.monotonicNow(); + namesystem.writeLock(); long startPostponedMisReplicatedBlocksCount = getPostponedMisreplicatedBlocksCount(); - namesystem.writeLock(); try { // blocksPerRescan is the configured number of blocks per rescan. // Randomly select blocksPerRescan consecutive blocks from the HashSet @@ -2333,9 +2333,9 @@ public class BlockManager implements BlockStatsMXBean { } } } finally { - namesystem.writeUnlock(); long endPostponedMisReplicatedBlocksCount = getPostponedMisreplicatedBlocksCount(); + namesystem.writeUnlock(); LOG.info("Rescan of postponedMisreplicatedBlocks completed in " + (Time.monotonicNow() - startTimeRescanPostponedMisReplicatedBlocks) + " msecs. " + endPostponedMisReplicatedBlocksCount +