HDFS-9812. Streamer threads leak if failure happens when closing DFSOutputStream. Contributed by Lin Yiqun.
(cherry picked from commit 352d299cf8
)
This commit is contained in:
parent
fed2339e28
commit
fe0009a2bd
|
@ -774,14 +774,19 @@ public class DFSOutputStream extends FSOutputSummer
|
||||||
flushInternal(); // flush all data to Datanodes
|
flushInternal(); // flush all data to Datanodes
|
||||||
// get last block before destroying the streamer
|
// get last block before destroying the streamer
|
||||||
ExtendedBlock lastBlock = getStreamer().getBlock();
|
ExtendedBlock lastBlock = getStreamer().getBlock();
|
||||||
closeThreads(false);
|
|
||||||
try (TraceScope ignored =
|
try (TraceScope ignored =
|
||||||
dfsClient.getTracer().newScope("completeFile")) {
|
dfsClient.getTracer().newScope("completeFile")) {
|
||||||
completeFile(lastBlock);
|
completeFile(lastBlock);
|
||||||
}
|
}
|
||||||
} catch (ClosedChannelException ignored) {
|
} catch (ClosedChannelException ignored) {
|
||||||
} finally {
|
} finally {
|
||||||
setClosed();
|
// Failures may happen when flushing data.
|
||||||
|
// Streamers may keep waiting for the new block information.
|
||||||
|
// Thus need to force closing these threads.
|
||||||
|
// Don't need to call setClosed() because closeThreads(true)
|
||||||
|
// calls setClosed() in the finally block.
|
||||||
|
closeThreads(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue