Repository: hadoop Updated Branches: refs/heads/HDFS-7240 f0d6a3eaa -> b06f4f63e
HDFS-12361. Ozone: SCM failed to start when a container metadata is empty. Contributed by Weiwei Yang. Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/b06f4f63 Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/b06f4f63 Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/b06f4f63 Branch: refs/heads/HDFS-7240 Commit: b06f4f63e350d3276da989843ab778d3b5679ae8 Parents: f0d6a3e Author: Anu Engineer <aengin...@apache.org> Authored: Mon Aug 28 13:20:45 2017 -0700 Committer: Anu Engineer <aengin...@apache.org> Committed: Mon Aug 28 13:20:45 2017 -0700 ---------------------------------------------------------------------- .../common/impl/ContainerManagerImpl.java | 34 +++++++++++--------- 1 file changed, 19 insertions(+), 15 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hadoop/blob/b06f4f63/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/container/common/impl/ContainerManagerImpl.java ---------------------------------------------------------------------- diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/container/common/impl/ContainerManagerImpl.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/container/common/impl/ContainerManagerImpl.java index aa6946c..7b65c3f 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/container/common/impl/ContainerManagerImpl.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/container/common/impl/ContainerManagerImpl.java @@ -207,28 +207,32 @@ public class ContainerManagerImpl implements ContainerManager { dis = new DigestInputStream(containerStream, sha); - ContainerData containerData = ContainerData.getFromProtBuf( - ContainerProtos.ContainerData.parseDelimitedFrom(dis)); - - - ContainerProtos.ContainerMeta meta = ContainerProtos.ContainerMeta - .parseDelimitedFrom(metaStream); - - if (meta != null && - !DigestUtils.sha256Hex(sha.digest()).equals(meta.getHash())) { + ContainerProtos.ContainerData containerDataProto = + ContainerProtos.ContainerData.parseDelimitedFrom(dis); + ContainerData containerData; + if (containerDataProto == null) { + // Sometimes container metadata might have been created but empty, + // when loading the info we get a null, this often means last time + // SCM was ending up at some middle phase causing that the metadata + // was not populated. Such containers are marked as inactive. + containerMap.put(keyName, new ContainerStatus(null, false)); + return; + } + containerData = ContainerData.getFromProtBuf(containerDataProto); + ContainerProtos.ContainerMeta meta = + ContainerProtos.ContainerMeta.parseDelimitedFrom(metaStream); + if (meta != null && !DigestUtils.sha256Hex(sha.digest()) + .equals(meta.getHash())) { // This means we were not able read data from the disk when booted the // datanode. We are going to rely on SCM understanding that we don't - // have - // valid data for this container when we send container reports. + // have valid data for this container when we send container reports. // Hopefully SCM will ask us to delete this container and rebuild it. - LOG.error("Invalid SHA found for container data. Name :{}" + - "cowardly refusing to read invalid data", containerName); + LOG.error("Invalid SHA found for container data. Name :{}" + + "cowardly refusing to read invalid data", containerName); containerMap.put(keyName, new ContainerStatus(null, false)); return; } - containerMap.put(keyName, new ContainerStatus(containerData, true)); - } catch (IOException | NoSuchAlgorithmException ex) { LOG.error("read failed for file: {} ex: {}", containerName, ex.getMessage()); --------------------------------------------------------------------- To unsubscribe, e-mail: common-commits-unsubscr...@hadoop.apache.org For additional commands, e-mail: common-commits-h...@hadoop.apache.org