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

This commit is contained in:
Tsz-Wo Nicholas Sze 2015-12-02 17:39:28 -08:00
parent 6af5255b02
commit afc76eb218
2 changed files with 20 additions and 11 deletions

View File

@ -701,13 +701,17 @@ public class DFSOutputStream extends FSOutputSummer
* Aborts this output stream and releases any system * Aborts this output stream and releases any system
* resources associated with this stream. * resources associated with this stream.
*/ */
synchronized void abort() throws IOException { void abort() throws IOException {
synchronized (this) {
if (isClosed()) { if (isClosed()) {
return; return;
} }
getStreamer().getLastException().set(new IOException("Lease timeout of " getStreamer().getLastException().set(
+ (dfsClient.getConf().getHdfsTimeout() / 1000) + " seconds expired.")); new IOException("Lease timeout of "
+ (dfsClient.getConf().getHdfsTimeout() / 1000)
+ " seconds expired."));
closeThreads(true); closeThreads(true);
}
dfsClient.endFileLease(fileId); dfsClient.endFileLease(fileId);
} }
@ -740,12 +744,15 @@ public class DFSOutputStream extends FSOutputSummer
* resources associated with this stream. * resources associated with this stream.
*/ */
@Override @Override
public synchronized void close() throws IOException { public void close() throws IOException {
try (TraceScope ignored = synchronized (this) {
dfsClient.newPathTraceScope("DFSOutputStream#close", src)) { try (TraceScope ignored = dfsClient.newPathTraceScope(
"DFSOutputStream#close", src)) {
closeImpl(); closeImpl();
} }
} }
dfsClient.endFileLease(fileId);
}
protected synchronized void closeImpl() throws IOException { protected synchronized void closeImpl() throws IOException {
if (isClosed()) { if (isClosed()) {
@ -772,7 +779,6 @@ public class DFSOutputStream extends FSOutputSummer
dfsClient.getTracer().newScope("completeFile")) { dfsClient.getTracer().newScope("completeFile")) {
completeFile(lastBlock); completeFile(lastBlock);
} }
dfsClient.endFileLease(fileId);
} catch (ClosedChannelException ignored) { } catch (ClosedChannelException ignored) {
} finally { } finally {
setClosed(); setClosed();

View File

@ -1658,6 +1658,9 @@ Release 2.7.2 - UNRELEASED
HDFS-9426. Rollingupgrade finalization is not backward compatible HDFS-9426. Rollingupgrade finalization is not backward compatible
(Kihwal Lee via vinayakumarb) (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 Release 2.7.1 - 2015-07-06
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES