diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index b3b0607af1a..913040f7693 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -227,6 +227,9 @@ Release 2.8.0 - UNRELEASED HDFS-7993. Provide each Replica details in fsck (J.Andreina via vinayakumarb) + HDFS-8217. During block recovery for truncate Log new Block Id in case of + copy-on-truncate is true. (vinayakumarb) + Release 2.7.1 - UNRELEASED INCOMPATIBLE CHANGES diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataNode.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataNode.java index a13a31f2b6d..ba02be24444 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataNode.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataNode.java @@ -2847,7 +2847,9 @@ private static void logRecoverBlock(String who, RecoveringBlock rb) { LOG.info(who + " calls recoverBlock(" + block + ", targets=[" + Joiner.on(", ").join(targets) + "]" - + ", newGenerationStamp=" + rb.getNewGenerationStamp() + ")"); + + ((rb.getNewBlock() == null) ? ", newGenerationStamp=" + + rb.getNewGenerationStamp() : ", newBlock=" + rb.getNewBlock()) + + ")"); } @Override // ClientDataNodeProtocol diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java index 4249fecb4e1..f175301361b 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java @@ -4225,6 +4225,8 @@ void commitBlockSynchronization(ExtendedBlock oldBlock, String src = ""; waitForLoadingFSImage(); writeLock(); + boolean copyTruncate = false; + BlockInfoContiguousUnderConstruction truncatedBlock = null; try { checkOperation(OperationCategory.WRITE); // If a DN tries to commit to the standby, the recovery will @@ -4281,11 +4283,10 @@ void commitBlockSynchronization(ExtendedBlock oldBlock, return; } - BlockInfoContiguousUnderConstruction truncatedBlock = - (BlockInfoContiguousUnderConstruction) iFile.getLastBlock(); + truncatedBlock = (BlockInfoContiguousUnderConstruction) iFile + .getLastBlock(); long recoveryId = truncatedBlock.getBlockRecoveryId(); - boolean copyTruncate = - truncatedBlock.getBlockId() != storedBlock.getBlockId(); + copyTruncate = truncatedBlock.getBlockId() != storedBlock.getBlockId(); if(recoveryId != newgenerationstamp) { throw new IOException("The recovery id " + newgenerationstamp + " does not match current recovery id " @@ -4378,7 +4379,8 @@ void commitBlockSynchronization(ExtendedBlock oldBlock, if (closeFile) { LOG.info("commitBlockSynchronization(oldBlock=" + oldBlock + ", file=" + src - + ", newgenerationstamp=" + newgenerationstamp + + (copyTruncate ? ", newBlock=" + truncatedBlock + : ", newgenerationstamp=" + newgenerationstamp) + ", newlength=" + newlength + ", newtargets=" + Arrays.asList(newtargets) + ") successful"); } else {