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 42a2bddcb7
commit 4123650e92
2 changed files with 21 additions and 14 deletions

View File

@ -123,6 +123,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

View File

@ -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 {
void abort() throws IOException {
synchronized (this) {
if (isClosed()) {
return;
}
streamer.setLastException(new IOException("Lease timeout of "
+ (dfsClient.getHdfsTimeout()/1000) + " seconds expired."));
+ (dfsClient.getHdfsTimeout() / 1000) + " seconds expired."));
closeThreads(true);
}
dfsClient.endFileLease(fileId);
}
@ -2226,15 +2228,18 @@ public class DFSOutputStream extends FSOutputSummer
* resources associated with this stream.
*/
@Override
public synchronized void close() throws IOException {
TraceScope scope =
dfsClient.getPathTraceScope("DFSOutputStream#close", src);
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 {
if (isClosed()) {
@ -2268,7 +2273,6 @@ public class DFSOutputStream extends FSOutputSummer
} finally {
scope.close();
}
dfsClient.endFileLease(fileId);
} catch (ClosedChannelException e) {
} finally {
setClosed();