FAQ
Repository: hive
Updated Branches:
   refs/heads/branch-1 caf4b516b -> 16be11ba5


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/16be11ba
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/16be11ba
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/16be11ba

Branch: refs/heads/branch-1
Commit: 16be11ba570b4a92d0833bb432c8393bafc4456e
Parents: caf4b51
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:24:05 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/16be11ba/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/16be11ba/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 b17942e..c8299fd 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
@@ -1525,10 +1525,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

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 2 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