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 f8e52b7c435..58787560cca 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 @@ -701,13 +701,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); } @@ -740,11 +744,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 { @@ -772,7 +779,6 @@ public class DFSOutputStream extends FSOutputSummer dfsClient.getTracer().newScope("completeFile")) { completeFile(lastBlock); } - dfsClient.endFileLease(fileId); } catch (ClosedChannelException ignored) { } finally { setClosed(); diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 0231f93d357..695183253b0 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -1658,6 +1658,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