浏览代码

HDFS-415. BlockReceiver hangs in case of certain runtime exceptions. (Konstantin Boudnik via rangadi)

git-svn-id: https://svn.apache.org/repos/asf/hadoop/hdfs/trunk@793111 13f79535-47bb-0310-9956-ffa450edef68
Raghu Angadi 16 年之前
父节点
当前提交
f551b3b8e5
共有 2 个文件被更改,包括 13 次插入5 次删除
  1. 3 0
      CHANGES.txt
  2. 10 5
      src/java/org/apache/hadoop/hdfs/server/datanode/BlockReceiver.java

+ 3 - 0
CHANGES.txt

@@ -62,6 +62,9 @@ Trunk (unreleased changes)
     HDFS-438. Check for NULL before invoking GenericArgumentParser in
     HDFS-438. Check for NULL before invoking GenericArgumentParser in
     DataNode. (Raghu Angadi)
     DataNode. (Raghu Angadi)
 
 
+    HDFS-415. BlockReceiver hangs in case of certain runtime exceptions.
+    (Konstantin Boudnik via rangadi)
+
 Release 0.20.1 - Unreleased
 Release 0.20.1 - Unreleased
 
 
   IMPROVEMENTS
   IMPROVEMENTS

+ 10 - 5
src/java/org/apache/hadoop/hdfs/server/datanode/BlockReceiver.java

@@ -502,6 +502,7 @@ class BlockReceiver implements java.io.Closeable, FSConstants {
       String mirrAddr, BlockTransferThrottler throttlerArg,
       String mirrAddr, BlockTransferThrottler throttlerArg,
       int numTargets) throws IOException {
       int numTargets) throws IOException {
 
 
+      boolean responderClosed = false;
       mirrorOut = mirrOut;
       mirrorOut = mirrOut;
       mirrorAddr = mirrAddr;
       mirrorAddr = mirrAddr;
       throttler = throttlerArg;
       throttler = throttlerArg;
@@ -535,8 +536,10 @@ class BlockReceiver implements java.io.Closeable, FSConstants {
 
 
       // wait for all outstanding packet responses. And then
       // wait for all outstanding packet responses. And then
       // indicate responder to gracefully shutdown.
       // indicate responder to gracefully shutdown.
+      // Mark that responder has been closed for future processing
       if (responder != null) {
       if (responder != null) {
         ((PacketResponder)responder.getRunnable()).close();
         ((PacketResponder)responder.getRunnable()).close();
+        responderClosed = true;
       }
       }
 
 
       // if this write is for a replication request (and not
       // if this write is for a replication request (and not
@@ -555,13 +558,15 @@ class BlockReceiver implements java.io.Closeable, FSConstants {
     } catch (IOException ioe) {
     } catch (IOException ioe) {
       LOG.info("Exception in receiveBlock for block " + block + 
       LOG.info("Exception in receiveBlock for block " + block + 
                " " + ioe);
                " " + ioe);
-      IOUtils.closeStream(this);
-      if (responder != null) {
-        responder.interrupt();
-      }
-      cleanupBlock();
       throw ioe;
       throw ioe;
     } finally {
     } finally {
+      if (!responderClosed) { // Abnormal termination of the flow above
+        IOUtils.closeStream(this);
+        if (responder != null) {
+          responder.interrupt();
+        }
+        cleanupBlock();
+      }
       if (responder != null) {
       if (responder != null) {
         try {
         try {
           responder.join();
           responder.join();