HDFS-15227. NPE if the last block changes from COMMITTED to COMPLETE during FSCK. Contributed by Ayush Saxena.
This commit is contained in:
parent
b74e47e31a
commit
62c8015683
|
@ -38,6 +38,7 @@ import java.util.Set;
|
||||||
import java.util.concurrent.ThreadLocalRandom;
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
|
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
|
import org.apache.hadoop.hdfs.server.blockmanagement.BlockUnderConstructionFeature;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.apache.hadoop.classification.InterfaceAudience;
|
import org.apache.hadoop.classification.InterfaceAudience;
|
||||||
|
@ -871,16 +872,20 @@ public class NamenodeFsck implements DataEncryptionKeyFactory {
|
||||||
String blkName = block.toString();
|
String blkName = block.toString();
|
||||||
BlockInfo storedBlock = blockManager.getStoredBlock(
|
BlockInfo storedBlock = blockManager.getStoredBlock(
|
||||||
block.getLocalBlock());
|
block.getLocalBlock());
|
||||||
DatanodeStorageInfo[] storages = storedBlock
|
BlockUnderConstructionFeature uc =
|
||||||
.getUnderConstructionFeature().getExpectedStorageLocations();
|
storedBlock.getUnderConstructionFeature();
|
||||||
report.append('\n')
|
if (uc != null) {
|
||||||
.append("Under Construction Block:\n")
|
// BlockUnderConstructionFeature can be null, in case the block was
|
||||||
.append(blockNumber).append(". ").append(blkName)
|
// in committed state, and the IBR came just after the check.
|
||||||
.append(" len=").append(block.getNumBytes())
|
DatanodeStorageInfo[] storages = uc.getExpectedStorageLocations();
|
||||||
.append(" Expected_repl=" + storages.length);
|
report.append('\n').append("Under Construction Block:\n")
|
||||||
String info=getReplicaInfo(storedBlock);
|
.append(blockNumber).append(". ").append(blkName).append(" len=")
|
||||||
if (!info.isEmpty()){
|
.append(block.getNumBytes())
|
||||||
report.append(" ").append(info);
|
.append(" Expected_repl=" + storages.length);
|
||||||
|
String info = getReplicaInfo(storedBlock);
|
||||||
|
if (!info.isEmpty()) {
|
||||||
|
report.append(" ").append(info);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue