From 9a08999906824e8982ec3b47315f9b960474186a Mon Sep 17 00:00:00 2001 From: yliu Date: Tue, 4 Aug 2015 15:54:23 +0800 Subject: [PATCH] HDFS-8850. VolumeScanner thread exits with exception if there is no block pool to be scanned but there are suspicious blocks. (Colin Patrick McCabe via yliu) --- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 4 ++++ .../hadoop/hdfs/server/datanode/VolumeScanner.java | 12 +++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index a2d7c2f54ae..eeefd84d14f 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -1109,6 +1109,10 @@ Release 2.8.0 - UNRELEASED HDFS-8847. change TestHDFSContractAppend to not override testRenameFileBeingAppended method. (Zhihai Xu) + HDFS-8850. VolumeScanner thread exits with exception if there is no block + pool to be scanned but there are suspicious blocks. (Colin Patrick McCabe + via yliu) + Release 2.7.2 - UNRELEASED INCOMPATIBLE CHANGES diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/VolumeScanner.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/VolumeScanner.java index ff655c27bdf..212e13b369d 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/VolumeScanner.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/VolumeScanner.java @@ -536,11 +536,13 @@ public class VolumeScanner extends Thread { return 0; } } - long saveDelta = monotonicMs - curBlockIter.getLastSavedMs(); - if (saveDelta >= conf.cursorSaveMs) { - LOG.debug("{}: saving block iterator {} after {} ms.", - this, curBlockIter, saveDelta); - saveBlockIterator(curBlockIter); + if (curBlockIter != null) { + long saveDelta = monotonicMs - curBlockIter.getLastSavedMs(); + if (saveDelta >= conf.cursorSaveMs) { + LOG.debug("{}: saving block iterator {} after {} ms.", + this, curBlockIter, saveDelta); + saveBlockIterator(curBlockIter); + } } bytesScanned = scanBlock(block, conf.targetBytesPerSec); if (bytesScanned >= 0) {