Skip to content

Commit 74634eb

Browse files
committed
HDFS-15644. Failed volumes can cause DNs to stop block reporting. Contributed by Ahmed Hussein.
1 parent e7aa4da commit 74634eb

File tree

1 file changed

+16
-12
lines changed
  • hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl

1 file changed

+16
-12
lines changed

hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/FsDatasetImpl.java

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1957,28 +1957,32 @@ public Map<DatanodeStorage, BlockListAsLongs> getBlockReports(String bpid) {
19571957
continue;
19581958
}
19591959
String volStorageID = b.getVolume().getStorageID();
1960-
if (!builders.containsKey(volStorageID)) {
1961-
if (!missingVolumesReported.contains(volStorageID)) {
1962-
LOG.warn("Storage volume: " + volStorageID + " missing for the"
1963-
+ " replica block: " + b + ". Probably being removed!");
1964-
missingVolumesReported.add(volStorageID);
1965-
}
1966-
continue;
1967-
}
19681960
switch(b.getState()) {
19691961
case FINALIZED:
19701962
case RBW:
19711963
case RWR:
1972-
builders.get(volStorageID).add(b);
19731964
break;
19741965
case RUR:
1975-
ReplicaInfo orig = b.getOriginalReplica();
1976-
builders.get(volStorageID).add(orig);
1966+
// use the original replica.
1967+
b = b.getOriginalReplica();
19771968
break;
19781969
case TEMPORARY:
1979-
break;
1970+
continue;
19801971
default:
19811972
assert false : "Illegal ReplicaInfo state.";
1973+
continue;
1974+
}
1975+
BlockListAsLongs.Builder storageBuilder = builders.get(volStorageID);
1976+
// a storage in the process of failing will not be in the volumes list
1977+
// but will be in the replica map.
1978+
if (storageBuilder != null) {
1979+
storageBuilder.add(b);
1980+
} else {
1981+
if (!missingVolumesReported.contains(volStorageID)) {
1982+
LOG.warn("Storage volume: " + volStorageID + " missing for the"
1983+
+ " replica block: " + b + ". Probably being removed!");
1984+
missingVolumesReported.add(volStorageID);
1985+
}
19821986
}
19831987
}
19841988
}

0 commit comments

Comments
 (0)