You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by da...@apache.org on 2015/12/06 02:32:51 UTC

hive git commit: HIVE-12583: HS2 ShutdownHookManager holds extra of Driver instance (Daniel Dai, reviewed by Sergey Shelukhin)

Repository: hive
Updated Branches:
  refs/heads/master 6cc5761b0 -> 7a1f14c4d


HIVE-12583: HS2 ShutdownHookManager holds extra of Driver instance (Daniel Dai, reviewed by Sergey Shelukhin)


Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/7a1f14c4
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/7a1f14c4
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/7a1f14c4

Branch: refs/heads/master
Commit: 7a1f14c4d9dd267012e43c1ccd051d64bc65698b
Parents: 6cc5761
Author: Daniel Dai <da...@hortonworks.com>
Authored: Sat Dec 5 17:31:41 2015 -0800
Committer: Daniel Dai <da...@hortonworks.com>
Committed: Sat Dec 5 17:31:59 2015 -0800

----------------------------------------------------------------------
 .../java/org/apache/hadoop/hive/ql/Driver.java  | 29 ++++++++++++--------
 1 file changed, 17 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/7a1f14c4/ql/src/java/org/apache/hadoop/hive/ql/Driver.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/Driver.java b/ql/src/java/org/apache/hadoop/hive/ql/Driver.java
index 62b608c..d81e17a 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/Driver.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/Driver.java
@@ -131,6 +131,7 @@ public class Driver implements CommandProcessor {
   private static final Logger LOG = LoggerFactory.getLogger(CLASS_NAME);
   static final private LogHelper console = new LogHelper(LOG);
   static final int SHUTDOWN_HOOK_PRIORITY = 0;
+  private Runnable shutdownRunner = null;
 
   private int maxRows = 100;
   ByteStream.Output bos = new ByteStream.Output();
@@ -400,18 +401,19 @@ public class Driver implements CommandProcessor {
       // Initialize the transaction manager.  This must be done before analyze is called.
       final HiveTxnManager txnManager = SessionState.get().initTxnMgr(conf);
       // In case when user Ctrl-C twice to kill Hive CLI JVM, we want to release locks
-      ShutdownHookManager.addShutdownHook(
-          new Runnable() {
-            @Override
-            public void run() {
-              try {
-                releaseLocksAndCommitOrRollback(false, txnManager);
-              } catch (LockException e) {
-                LOG.warn("Exception when releasing locks in ShutdownHook for Driver: " +
-                    e.getMessage());
-              }
-            }
-          }, SHUTDOWN_HOOK_PRIORITY);
+
+      shutdownRunner = new Runnable() {
+        @Override
+        public void run() {
+          try {
+            releaseLocksAndCommitOrRollback(false, txnManager);
+          } catch (LockException e) {
+            LOG.warn("Exception when releasing locks in ShutdownHook for Driver: " +
+                e.getMessage());
+          }
+        }
+      };
+      ShutdownHookManager.addShutdownHook(shutdownRunner, SHUTDOWN_HOOK_PRIORITY);
 
       command = new VariableSubstitution(new HiveVariableSource() {
         @Override
@@ -1950,6 +1952,9 @@ public class Driver implements CommandProcessor {
         LOG.warn("Exception when releasing locking in destroy: " +
             e.getMessage());
       }
+      if (shutdownRunner != null) {
+        ShutdownHookManager.removeShutdownHook(shutdownRunner);
+      }
     }
   }