hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From szets...@apache.org
Subject hadoop git commit: HDFS-9294. DFSClient deadlock when close file and failed to renew lease. Contributed by Brahma Reddy Battula
Date Thu, 03 Dec 2015 02:09:35 GMT
Repository: hadoop
Updated Branches:
  refs/heads/branch-2.7.2 c62d42cd8 -> 2311560ec


HDFS-9294. DFSClient deadlock when close file and failed to renew lease.  Contributed by Brahma
Reddy Battula


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/2311560e
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/2311560e
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/2311560e

Branch: refs/heads/branch-2.7.2
Commit: 2311560ecad28845160a41c987f816dcd1623cf8
Parents: c62d42c
Author: Tsz-Wo Nicholas Sze <szetszwo@hortonworks.com>
Authored: Wed Dec 2 17:39:28 2015 -0800
Committer: Tsz-Wo Nicholas Sze <szetszwo@hortonworks.com>
Committed: Wed Dec 2 17:58:10 2015 -0800

----------------------------------------------------------------------
 hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt     |  3 ++
 .../org/apache/hadoop/hdfs/DFSOutputStream.java | 32 +++++++++++---------
 2 files changed, 21 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/2311560e/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
index 4fefe52..69c5c41 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
+++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
@@ -98,6 +98,9 @@ Release 2.7.2 - 2015-11-11
     HDFS-9426. Rollingupgrade finalization is not backward compatible
     (Kihwal Lee via vinayakumarb)
 
+    HDFS-9294. DFSClient deadlock when close file and failed to renew lease.
+    (Brahma Reddy Battula via szetszwo)
+
 Release 2.7.1 - 2015-07-06
 
   INCOMPATIBLE CHANGES

http://git-wip-us.apache.org/repos/asf/hadoop/blob/2311560e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSOutputStream.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSOutputStream.java
b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSOutputStream.java
index def829c..d6c239e 100755
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSOutputStream.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSOutputStream.java
@@ -2174,13 +2174,15 @@ public class DFSOutputStream extends FSOutputSummer
    * Aborts this output stream and releases any system 
    * resources associated with this stream.
    */
-  synchronized void abort() throws IOException {
-    if (isClosed()) {
-      return;
+  void abort() throws IOException {
+    synchronized (this) {
+      if (isClosed()) {
+        return;
+      }
+      streamer.setLastException(new IOException("Lease timeout of "
+          + (dfsClient.getHdfsTimeout() / 1000) + " seconds expired."));
+      closeThreads(true);
     }
-    streamer.setLastException(new IOException("Lease timeout of "
-        + (dfsClient.getHdfsTimeout()/1000) + " seconds expired."));
-    closeThreads(true);
     dfsClient.endFileLease(fileId);
   }
 
@@ -2226,14 +2228,17 @@ public class DFSOutputStream extends FSOutputSummer
    * resources associated with this stream.
    */
   @Override
-  public synchronized void close() throws IOException {
-    TraceScope scope =
-        dfsClient.getPathTraceScope("DFSOutputStream#close", src);
-    try {
-      closeImpl();
-    } finally {
-      scope.close();
+  public void close() throws IOException {
+    synchronized (this) {
+      TraceScope scope = dfsClient.getPathTraceScope("DFSOutputStream#close",
+          src);
+      try {
+        closeImpl();
+      } finally {
+        scope.close();
+      }
     }
+    dfsClient.endFileLease(fileId);
   }
 
   private synchronized void closeImpl() throws IOException {
@@ -2268,7 +2273,6 @@ public class DFSOutputStream extends FSOutputSummer
       } finally {
         scope.close();
       }
-      dfsClient.endFileLease(fileId);
     } catch (ClosedChannelException e) {
     } finally {
       setClosed();


Mime
View raw message