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 f4ba5ff1d7)
This commit is contained in:
Jing Zhao 2016-08-03 11:39:06 -07:00
parent 1ea03411c2
commit 180a26d9fb
1 changed files with 2 additions and 2 deletions

View File

@ -2073,9 +2073,9 @@ void rescanPostponedMisreplicatedBlocks() {
return; return;
} }
long startTimeRescanPostponedMisReplicatedBlocks = Time.monotonicNow(); long startTimeRescanPostponedMisReplicatedBlocks = Time.monotonicNow();
namesystem.writeLock();
long startPostponedMisReplicatedBlocksCount = long startPostponedMisReplicatedBlocksCount =
getPostponedMisreplicatedBlocksCount(); getPostponedMisreplicatedBlocksCount();
namesystem.writeLock();
try { try {
// blocksPerRescan is the configured number of blocks per rescan. // blocksPerRescan is the configured number of blocks per rescan.
// Randomly select blocksPerRescan consecutive blocks from the HashSet // Randomly select blocksPerRescan consecutive blocks from the HashSet
@ -2128,9 +2128,9 @@ void rescanPostponedMisreplicatedBlocks() {
} }
} }
} finally { } finally {
namesystem.writeUnlock();
long endPostponedMisReplicatedBlocksCount = long endPostponedMisReplicatedBlocksCount =
getPostponedMisreplicatedBlocksCount(); getPostponedMisreplicatedBlocksCount();
namesystem.writeUnlock();
LOG.info("Rescan of postponedMisreplicatedBlocks completed in " + LOG.info("Rescan of postponedMisreplicatedBlocks completed in " +
(Time.monotonicNow() - startTimeRescanPostponedMisReplicatedBlocks) + (Time.monotonicNow() - startTimeRescanPostponedMisReplicatedBlocks) +
" msecs. " + endPostponedMisReplicatedBlocksCount + " msecs. " + endPostponedMisReplicatedBlocksCount +