diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES_HDFS-5535.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES_HDFS-5535.txt index bba08bb624..9305b06942 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES_HDFS-5535.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES_HDFS-5535.txt @@ -90,3 +90,6 @@ HDFS-5535 subtasks: usage message. (Vinayakumar B via szetszwo) HDFS-6014. Fix findbug warnings introduced by HDFS-5583. (kihwal) + + HDFS-6015. Fix TestBlockRecovery + #testRaceBetweenReplicaRecoveryAndFinalizeBlock. (kihwal) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/BlockReceiver.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/BlockReceiver.java index 7417e10572..29d416ad52 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/BlockReceiver.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/BlockReceiver.java @@ -761,7 +761,13 @@ void receiveBlock( } if (responder != null) { try { - responder.join(datanode.getDnConf().getXceiverStopTimeout()); + responder.interrupt(); + // join() on the responder should timeout a bit earlier than the + // configured deadline. Otherwise, the join() on this thread will + // likely timeout as well. + long joinTimeout = datanode.getDnConf().getXceiverStopTimeout(); + joinTimeout = joinTimeout > 1 ? joinTimeout*8/10 : joinTimeout; + responder.join(joinTimeout); if (responder.isAlive()) { String msg = "Join on responder thread " + responder + " timed out"; diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestBlockRecovery.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestBlockRecovery.java index 80a9a8de96..4ff942b1f8 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestBlockRecovery.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestBlockRecovery.java @@ -586,6 +586,7 @@ public void testRaceBetweenReplicaRecoveryAndFinalizeBlock() throws Exception { tearDown();// Stop the Mocked DN started in startup() Configuration conf = new HdfsConfiguration(); + conf.set(DFSConfigKeys.DFS_DATANODE_XCEIVER_STOP_TIMEOUT_MILLIS_KEY, "1000"); MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf) .nnTopology(MiniDFSNNTopology.simpleSingleNN(8020, 50070)) .numDataNodes(1).build();