hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From asur...@apache.org
Subject [19/38] hadoop git commit: HDFS-9294. DFSClient deadlock when close file and failed to renew lease. Contributed by Brahma Reddy Battula
Date Sun, 06 Dec 2015 07:13:21 GMT
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/e8bd1ba7
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/e8bd1ba7
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/e8bd1ba7

Branch: refs/heads/yarn-2877
Commit: e8bd1ba74b2fc7a6a1b71d068ef01a0fb0bbe294
Parents: 6b9a5be
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:39:28 2015 -0800

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


http://git-wip-us.apache.org/repos/asf/hadoop/blob/e8bd1ba7/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DFSOutputStream.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DFSOutputStream.java
b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DFSOutputStream.java
index 836868b..f6a8981 100755
--- a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DFSOutputStream.java
+++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DFSOutputStream.java
@@ -708,13 +708,17 @@ 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;
+      }
+      getStreamer().getLastException().set(
+          new IOException("Lease timeout of "
+              + (dfsClient.getConf().getHdfsTimeout() / 1000)
+              + " seconds expired."));
+      closeThreads(true);
     }
-    getStreamer().getLastException().set(new IOException("Lease timeout of "
-        + (dfsClient.getConf().getHdfsTimeout() / 1000) + " seconds expired."));
-    closeThreads(true);
     dfsClient.endFileLease(fileId);
   }
 
@@ -747,11 +751,14 @@ public class DFSOutputStream extends FSOutputSummer
    * resources associated with this stream.
    */
   @Override
-  public synchronized void close() throws IOException {
-    try (TraceScope ignored =
-             dfsClient.newPathTraceScope("DFSOutputStream#close", src)) {
-      closeImpl();
+  public void close() throws IOException {
+    synchronized (this) {
+      try (TraceScope ignored = dfsClient.newPathTraceScope(
+          "DFSOutputStream#close", src)) {
+        closeImpl();
+      }
     }
+    dfsClient.endFileLease(fileId);
   }
 
   protected synchronized void closeImpl() throws IOException {
@@ -779,7 +786,6 @@ public class DFSOutputStream extends FSOutputSummer
                dfsClient.getTracer().newScope("completeFile")) {
         completeFile(lastBlock);
       }
-      dfsClient.endFileLease(fileId);
     } catch (ClosedChannelException ignored) {
     } finally {
       setClosed();

http://git-wip-us.apache.org/repos/asf/hadoop/blob/e8bd1ba7/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DFSStripedOutputStream.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DFSStripedOutputStream.java
b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DFSStripedOutputStream.java
index f5bae2a..9c98f9d 100644
--- a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DFSStripedOutputStream.java
+++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DFSStripedOutputStream.java
@@ -757,16 +757,19 @@ public class DFSStripedOutputStream extends DFSOutputStream {
   }
 
   @Override
-  synchronized void abort() throws IOException {
-    if (isClosed()) {
-      return;
-    }
-    for (StripedDataStreamer streamer : streamers) {
-      streamer.getLastException().set(new IOException("Lease timeout of "
-          + (dfsClient.getConf().getHdfsTimeout()/1000) +
-          " seconds expired."));
+  void abort() throws IOException {
+    synchronized (this) {
+      if (isClosed()) {
+        return;
+      }
+      for (StripedDataStreamer streamer : streamers) {
+        streamer.getLastException().set(
+            new IOException("Lease timeout of "
+                + (dfsClient.getConf().getHdfsTimeout() / 1000)
+                + " seconds expired."));
+      }
+      closeThreads(true);
     }
-    closeThreads(true);
     dfsClient.endFileLease(fileId);
   }
 
@@ -954,7 +957,6 @@ public class DFSStripedOutputStream extends DFSOutputStream {
                dfsClient.getTracer().newScope("completeFile")) {
         completeFile(currentBlockGroup);
       }
-      dfsClient.endFileLease(fileId);
     } catch (ClosedChannelException ignored) {
     } finally {
       setClosed();

http://git-wip-us.apache.org/repos/asf/hadoop/blob/e8bd1ba7/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 bb3f148..b65c048 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
+++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
@@ -2535,6 +2535,9 @@ Release 2.7.2 - UNRELEASED
     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


Mime
View raw message