HDFS-11018. Incorrect check and message in FsDatasetImpl#invalidate. Contributed by Yiqun Lin.

(cherry picked from commit 6d2da38d16)

Conflicts:
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/FsDatasetImpl.java
This commit is contained in:
Wei-Chiu Chuang 2016-10-20 10:49:39 -07:00
parent ab36519b6f
commit 6f4192d77d
1 changed files with 20 additions and 10 deletions

View File

@ -809,8 +809,14 @@ class FsDatasetImpl implements FsDatasetSpi<FsVolumeImpl> {
throws ReplicaNotFoundException { throws ReplicaNotFoundException {
ReplicaInfo info = volumeMap.get(b.getBlockPoolId(), b.getLocalBlock()); ReplicaInfo info = volumeMap.get(b.getBlockPoolId(), b.getLocalBlock());
if (info == null) { if (info == null) {
if (volumeMap.get(b.getBlockPoolId(), b.getLocalBlock().getBlockId())
== null) {
throw new ReplicaNotFoundException( throw new ReplicaNotFoundException(
ReplicaNotFoundException.NON_EXISTENT_REPLICA + b); ReplicaNotFoundException.NON_EXISTENT_REPLICA + b);
} else {
throw new ReplicaNotFoundException(
ReplicaNotFoundException.UNEXPECTED_GS_REPLICA + b);
}
} }
return info; return info;
} }
@ -1996,14 +2002,18 @@ class FsDatasetImpl implements FsDatasetSpi<FsVolumeImpl> {
try(AutoCloseableLock lock = datasetLock.acquire()) { try(AutoCloseableLock lock = datasetLock.acquire()) {
final ReplicaInfo info = volumeMap.get(bpid, invalidBlks[i]); final ReplicaInfo info = volumeMap.get(bpid, invalidBlks[i]);
if (info == null) { if (info == null) {
// It is okay if the block is not found -- it may be deleted earlier. ReplicaInfo infoByBlockId =
volumeMap.get(bpid, invalidBlks[i].getBlockId());
if (infoByBlockId == null) {
// It is okay if the block is not found -- it
// may be deleted earlier.
LOG.info("Failed to delete replica " + invalidBlks[i] LOG.info("Failed to delete replica " + invalidBlks[i]
+ ": ReplicaInfo not found."); + ": ReplicaInfo not found.");
continue; } else {
}
if (info.getGenerationStamp() != invalidBlks[i].getGenerationStamp()) {
errors.add("Failed to delete replica " + invalidBlks[i] errors.add("Failed to delete replica " + invalidBlks[i]
+ ": GenerationStamp not matched, info=" + info); + ": GenerationStamp not matched, existing replica is "
+ Block.toString(infoByBlockId));
}
continue; continue;
} }
f = info.getBlockFile(); f = info.getBlockFile();