Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 3FA58200CBC for ; Tue, 20 Jun 2017 16:20:57 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 3E83D160BE1; Tue, 20 Jun 2017 14:20:57 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 83C70160BD3 for ; Tue, 20 Jun 2017 16:20:56 +0200 (CEST) Received: (qmail 4515 invoked by uid 500); 20 Jun 2017 14:20:55 -0000 Mailing-List: contact common-commits-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list common-commits@hadoop.apache.org Received: (qmail 4506 invoked by uid 99); 20 Jun 2017 14:20:55 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 20 Jun 2017 14:20:55 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 754E1DFB94; Tue, 20 Jun 2017 14:20:55 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: kihwal@apache.org To: common-commits@hadoop.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: hadoop git commit: HDFS-11960. Successfully closed files can stay under-replicated. Contributed by Kihwal Lee. Date: Tue, 20 Jun 2017 14:20:55 +0000 (UTC) archived-at: Tue, 20 Jun 2017 14:20:57 -0000 Repository: hadoop Updated Branches: refs/heads/branch-2.8 a526c3b0b -> 40e3cd24b HDFS-11960. Successfully closed files can stay under-replicated. Contributed by Kihwal Lee. (cherry picked from commit 8f533ca76b3f3592dc8ec6e318382a54becf10f5) Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/40e3cd24 Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/40e3cd24 Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/40e3cd24 Branch: refs/heads/branch-2.8 Commit: 40e3cd24b068d08be8cf05668290b908f6b43c11 Parents: a526c3b Author: Kihwal Lee Authored: Tue Jun 20 09:20:02 2017 -0500 Committer: Kihwal Lee Committed: Tue Jun 20 09:20:02 2017 -0500 ---------------------------------------------------------------------- .../server/blockmanagement/BlockManager.java | 5 ++- .../blockmanagement/TestPendingReplication.java | 45 ++++++++++++++++++++ 2 files changed, 48 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hadoop/blob/40e3cd24/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockManager.java ---------------------------------------------------------------------- diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockManager.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockManager.java index ed00cd1..b491f61 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockManager.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockManager.java @@ -3237,8 +3237,9 @@ public class BlockManager implements BlockStatsMXBean { // Modify the blocks->datanode map and node's map. // BlockInfo storedBlock = getStoredBlock(block); - if (storedBlock != null) { - pendingReplications.decrement(getStoredBlock(block), node); + if (storedBlock != null && + block.getGenerationStamp() == storedBlock.getGenerationStamp()) { + pendingReplications.decrement(storedBlock, node); } processAndHandleReportedBlock(storageInfo, block, ReplicaState.FINALIZED, delHintNode); http://git-wip-us.apache.org/repos/asf/hadoop/blob/40e3cd24/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/blockmanagement/TestPendingReplication.java ---------------------------------------------------------------------- diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/blockmanagement/TestPendingReplication.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/blockmanagement/TestPendingReplication.java index afda6e8..b77dbc7 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/blockmanagement/TestPendingReplication.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/blockmanagement/TestPendingReplication.java @@ -209,6 +209,8 @@ public class TestPendingReplication { // Place into blocksmap with GenerationStamp = 1 blockInfo.setGenerationStamp(1); blocksMap.addBlockCollection(blockInfo, bc); + //Save it for later. + BlockInfo storedBlock = blockInfo; assertEquals("Size of pendingReplications ", 1, pendingReplications.size()); @@ -255,6 +257,49 @@ public class TestPendingReplication { // Verify size of neededReplications is exactly 1. assertEquals("size of neededReplications is 1 ", 1, neededReplications.size()); + + // Verify HDFS-11960 + // Stop the replication/redundancy monitor + BlockManagerTestUtil.stopReplicationThread(blkManager); + pendingReplications.clear(); + // Pick a real node + DatanodeDescriptor desc[] = { blkManager.getDatanodeManager(). + getDatanodes().iterator().next() }; + + // Add a stored block to the pendingReconstruction. + pendingReplications.increment(storedBlock, desc); + assertEquals("Size of pendingReplications ", 1, + pendingReplications.size()); + + // A received IBR processing calls addBlock(). If the gen stamp in the + // report is not the same, it should stay in pending. + fsn.writeLock(); + try { + // Use a wrong gen stamp. + blkManager.addBlock(desc[0].getStorageInfos()[0], + new Block(1, 1, 0), null); + } finally { + fsn.writeUnlock(); + } + + // The block should still be pending + assertEquals("Size of pendingReplications ", 1, + pendingReplications.size()); + + // A block report with the correct gen stamp should remove the record + // from the pending queue. + fsn.writeLock(); + try { + blkManager.addBlock(desc[0].getStorageInfos()[0], + new Block(1, 1, 1), null); + } finally { + fsn.writeUnlock(); + } + + // The pending queue should be empty. + assertEquals("Size of pendingReplications ", 0, + pendingReplications.size()); + } finally { if (cluster != null) { cluster.shutdown(); --------------------------------------------------------------------- To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org For additional commands, e-mail: common-commits-help@hadoop.apache.org