From 180a26d9fb2b3f4a0632e1379f867020326c7702 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. (cherry picked from commit f4ba5ff1d70ef92d59851c09c4bd4b43d6c04971) --- .../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 0f6d6dd09ea..703200be350 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 @@ -2073,9 +2073,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 @@ -2128,9 +2128,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 +