FAQ
Repository: hive
Updated Branches:
   refs/heads/master 2bc0aed07 -> 4848aea7b


HIVE-12790: Metastore connection leaks in HiveServer2 (Naveen Gangam via Aihua Xu, reviewed by Thejas M Nair, Aihua Xu)


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

Branch: refs/heads/master
Commit: 4848aea7b0e5a8ce84bedc74bf3602864b1b8a46
Parents: 2bc0aed
Author: Aihua Xu <aihuaxu@apache.org>
Authored: Fri Feb 5 09:07:34 2016 -0500
Committer: Aihua Xu <aihuaxu@apache.org>
Committed: Fri Feb 5 09:07:34 2016 -0500

----------------------------------------------------------------------
  .../org/apache/hadoop/hive/ql/exec/TaskRunner.java | 12 ++++++++++++
  .../apache/hadoop/hive/ql/session/SessionState.java | 13 +++++++++----
  2 files changed, 21 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/4848aea7/ql/src/java/org/apache/hadoop/hive/ql/exec/TaskRunner.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/exec/TaskRunner.java b/ql/src/java/org/apache/hadoop/hive/ql/exec/TaskRunner.java
index ad0abde..f6fd081 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/exec/TaskRunner.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/exec/TaskRunner.java
@@ -21,8 +21,11 @@ package org.apache.hadoop.hive.ql.exec;
  import java.io.Serializable;
  import java.util.concurrent.atomic.AtomicLong;

+import org.apache.hadoop.hive.ql.metadata.Hive;
  import org.apache.hadoop.hive.ql.session.OperationLog;
  import org.apache.hadoop.hive.ql.session.SessionState;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;

  /**
   * TaskRunner implementation.
@@ -44,6 +47,8 @@ public class TaskRunner extends Thread {

    protected Thread runner;

+ private static transient final Logger LOG = LoggerFactory.getLogger(TaskRunner.class);
+
    public TaskRunner(Task<? extends Serializable> tsk, TaskResult result) {
      this.tsk = tsk;
      this.result = result;
@@ -74,6 +79,13 @@ public class TaskRunner extends Thread {
        SessionState.start(ss);
        runSequential();
      } finally {
+ try {
+ // Call Hive.closeCurrent() that closes the HMS connection, causes
+ // HMS connection leaks otherwise.
+ Hive.closeCurrent();
+ } catch (Exception e) {
+ LOG.warn("Exception closing Metastore connection:" + e.getMessage());
+ }
        runner = null;
        result.setRunning(false);
      }

http://git-wip-us.apache.org/repos/asf/hive/blob/4848aea7/ql/src/java/org/apache/hadoop/hive/ql/session/SessionState.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/session/SessionState.java b/ql/src/java/org/apache/hadoop/hive/ql/session/SessionState.java
index 99b38b5..15965ad 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/session/SessionState.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/session/SessionState.java
@@ -1466,10 +1466,15 @@ public class SessionState {
        tezSessionState = null;
      }

- closeSparkSession();
- registry.closeCUDFLoaders();
- dropSessionPaths(conf);
- unCacheDataNucleusClassLoaders();
+ try {
+ closeSparkSession();
+ registry.closeCUDFLoaders();
+ dropSessionPaths(conf);
+ unCacheDataNucleusClassLoaders();
+ } finally {
+ // removes the threadlocal variables, closes underlying HMS connection
+ Hive.closeCurrent();
+ }
    }

    private void unCacheDataNucleusClassLoaders() {

Search Discussions

Discussion Posts

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 1 of 3 | next ›
Discussion Overview
groupcommits @
categorieshive, hadoop
postedFeb 5, '16 at 2:09p
activeFeb 5, '16 at 2:24p
posts3
users1
websitehive.apache.org

1 user in discussion

Aihuaxu: 3 posts

People

Translate

site design / logo © 2021 Grokbase