From 3d5627b56320e96ac015746f46d94cf278986f8f Mon Sep 17 00:00:00 2001 From: Jian He Date: Thu, 11 Dec 2014 11:16:45 -0800 Subject: [PATCH] YARN-2917. Fixed potential deadlock when system.exit is called in AsyncDispatcher. Contributed by Rohith Sharmaks (cherry picked from commit 614b6afea450ebb897fbb2519c6f02e13b9bd12d) (cherry picked from commit 41f0d20fcb4fec5b932b8947a44f93345205222c) (cherry picked from commit aa4f8184ee7aa1817a9b23b3b4e7e78da95dc031) --- hadoop-yarn-project/CHANGES.txt | 3 +++ .../apache/hadoop/yarn/event/AsyncDispatcher.java | 15 +++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/hadoop-yarn-project/CHANGES.txt b/hadoop-yarn-project/CHANGES.txt index ca1bc2aad1d..852c9a15bfd 100644 --- a/hadoop-yarn-project/CHANGES.txt +++ b/hadoop-yarn-project/CHANGES.txt @@ -42,6 +42,9 @@ Release 2.6.1 - UNRELEASED YARN-2910. FSLeafQueue can throw ConcurrentModificationException. (Wilfred Spiegelenburg via kasha) + YARN-2917. Fixed potential deadlock when system.exit is called in AsyncDispatcher + (Rohith Sharmaks via jianhe) + Release 2.6.0 - 2014-11-18 INCOMPATIBLE CHANGES diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/event/AsyncDispatcher.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/event/AsyncDispatcher.java index 370b0f7324f..28be6acf732 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/event/AsyncDispatcher.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/event/AsyncDispatcher.java @@ -181,8 +181,9 @@ public class AsyncDispatcher extends AbstractService implements Dispatcher { if (exitOnDispatchException && (ShutdownHookManager.get().isShutdownInProgress()) == false && stopped == false) { - LOG.info("Exiting, bbye.."); - System.exit(-1); + Thread shutDownThread = new Thread(createShutDownThread()); + shutDownThread.setName("AsyncDispatcher ShutDown handler"); + shutDownThread.start(); } } } @@ -271,4 +272,14 @@ public class AsyncDispatcher extends AbstractService implements Dispatcher { } } + + Runnable createShutDownThread() { + return new Runnable() { + @Override + public void run() { + LOG.info("Exiting, bbye.."); + System.exit(-1); + } + }; + } }