diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 5968db526c..11f21b0957 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -424,6 +424,9 @@ Release 2.4.0 - UNRELEASED HDFS-6123. Do not log stack trace for ReplicaAlreadyExistsException and SocketTimeoutException. (szetszwo) + HDFS-6129. When a replica is not found for deletion, do not throw an + exception. (szetszwo) + OPTIMIZATIONS HDFS-5790. LeaseManager.findPath is very slow when many leases need recovery diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/FsDatasetImpl.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/FsDatasetImpl.java index 19233c8de1..e35737bd88 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/FsDatasetImpl.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/FsDatasetImpl.java @@ -1152,43 +1152,39 @@ static void checkReplicaFiles(final ReplicaInfo r) throws IOException { */ @Override // FsDatasetSpi public void invalidate(String bpid, Block invalidBlks[]) throws IOException { - boolean error = false; + final List errors = new ArrayList(); for (int i = 0; i < invalidBlks.length; i++) { final File f; final FsVolumeImpl v; synchronized (this) { - f = getFile(bpid, invalidBlks[i].getBlockId()); - ReplicaInfo info = volumeMap.get(bpid, invalidBlks[i]); + final ReplicaInfo info = volumeMap.get(bpid, invalidBlks[i]); if (info == null) { - LOG.warn("Failed to delete replica " + invalidBlks[i] + // It is okay if the block is not found -- it may be deleted earlier. + LOG.info("Failed to delete replica " + invalidBlks[i] + ": ReplicaInfo not found."); - error = true; continue; } if (info.getGenerationStamp() != invalidBlks[i].getGenerationStamp()) { - LOG.warn("Failed to delete replica " + invalidBlks[i] + errors.add("Failed to delete replica " + invalidBlks[i] + ": GenerationStamp not matched, info=" + info); - error = true; continue; } + f = info.getBlockFile(); v = (FsVolumeImpl)info.getVolume(); if (f == null) { - LOG.warn("Failed to delete replica " + invalidBlks[i] + errors.add("Failed to delete replica " + invalidBlks[i] + ": File not found, volume=" + v); - error = true; continue; } if (v == null) { - LOG.warn("Failed to delete replica " + invalidBlks[i] - + ". No volume for this replica, file=" + f + "."); - error = true; + errors.add("Failed to delete replica " + invalidBlks[i] + + ". No volume for this replica, file=" + f); continue; } File parent = f.getParentFile(); if (parent == null) { - LOG.warn("Failed to delete replica " + invalidBlks[i] - + ". Parent not found for file " + f + "."); - error = true; + errors.add("Failed to delete replica " + invalidBlks[i] + + ". Parent not found for file " + f); continue; } ReplicaState replicaState = info.getState(); @@ -1210,8 +1206,14 @@ public void invalidate(String bpid, Block invalidBlks[]) throws IOException { new ExtendedBlock(bpid, invalidBlks[i]), dataStorage.getTrashDirectoryForBlockFile(bpid, f)); } - if (error) { - throw new IOException("Error in deleting blocks."); + if (!errors.isEmpty()) { + StringBuilder b = new StringBuilder("Failed to delete ") + .append(errors.size()).append(" (out of ").append(invalidBlks.length) + .append(") replica(s):"); + for(int i = 0; i < errors.size(); i++) { + b.append("\n").append(i).append(") ").append(errors.get(i)); + } + throw new IOException(b.toString()); } }