hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ss...@apache.org
Subject hive git commit: HIVE-16325. Tez session refresh based on a time interval fails. (Siddharth Seth, reviewed by Sergey Shelukhin)
Date Wed, 29 Mar 2017 19:00:47 GMT
Repository: hive
Updated Branches:
  refs/heads/master 19865cb07 -> df796776b


HIVE-16325. Tez session refresh based on a time interval fails.  (Siddharth Seth, 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/df796776
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/df796776
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/df796776

Branch: refs/heads/master
Commit: df796776be53c6af2f4d6e50b6bc289e8d84dfa5
Parents: 19865cb
Author: Siddharth Seth <sseth@apache.org>
Authored: Wed Mar 29 12:00:22 2017 -0700
Committer: Siddharth Seth <sseth@apache.org>
Committed: Wed Mar 29 12:00:22 2017 -0700

----------------------------------------------------------------------
 .../hive/ql/exec/tez/TezSessionPoolManager.java | 21 ++++++++++++++++++--
 .../hive/ql/exec/tez/TezSessionState.java       |  4 ++++
 2 files changed, 23 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/df796776/ql/src/java/org/apache/hadoop/hive/ql/exec/tez/TezSessionPoolManager.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/exec/tez/TezSessionPoolManager.java b/ql/src/java/org/apache/hadoop/hive/ql/exec/tez/TezSessionPoolManager.java
index 8f45947..b4d8ffa 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/exec/tez/TezSessionPoolManager.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/exec/tez/TezSessionPoolManager.java
@@ -76,6 +76,7 @@ public class TezSessionPoolManager {
   private static final Logger LOG = LoggerFactory.getLogger(TezSessionPoolManager.class);
   private static final Random rdm = new Random();
 
+  private volatile SessionState initSessionState;
   private BlockingQueue<TezSessionPoolSession> defaultQueuePool;
 
   /** Priority queue sorted by expiration time of live sessions that could be expired. */
@@ -136,6 +137,8 @@ public class TezSessionPoolManager {
 
   public void startPool() throws Exception {
     if (initialSessions.isEmpty()) return;
+    // Hive SessionState available at this point.
+    initSessionState = SessionState.get();
     int threadCount = Math.min(initialSessions.size(),
         HiveConf.getIntVar(initConf, ConfVars.HIVE_SERVER2_TEZ_SESSION_MAX_INIT_THREADS));
     Preconditions.checkArgument(threadCount > 0);
@@ -259,13 +262,27 @@ public class TezSessionPoolManager {
       expirationThread = new Thread(new Runnable() {
         @Override
         public void run() {
-          runExpirationThread();
+          try {
+            SessionState.setCurrentSessionState(initSessionState);
+            runExpirationThread();
+          } catch (Exception e) {
+            LOG.warn("Exception in TezSessionPool-expiration thread. Thread will shut down",
e);
+          } finally {
+            LOG.info("TezSessionPool-expiration thread exiting");
+          }
         }
       }, "TezSessionPool-expiration");
       restartThread = new Thread(new Runnable() {
         @Override
         public void run() {
-          runRestartThread();
+          try {
+            SessionState.setCurrentSessionState(initSessionState);
+            runRestartThread();
+          } catch (Exception e) {
+            LOG.warn("Exception in TezSessionPool-cleanup thread. Thread will shut down",
e);
+          } finally {
+            LOG.info("TezSessionPool-cleanup thread exiting");
+          }
         }
       }, "TezSessionPool-cleanup");
     }

http://git-wip-us.apache.org/repos/asf/hive/blob/df796776/ql/src/java/org/apache/hadoop/hive/ql/exec/tez/TezSessionState.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/exec/tez/TezSessionState.java b/ql/src/java/org/apache/hadoop/hive/ql/exec/tez/TezSessionState.java
index ed1ba9c..036e918 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/exec/tez/TezSessionState.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/exec/tez/TezSessionState.java
@@ -345,6 +345,7 @@ public class TezSessionState {
       String user, final Configuration conf) throws IOException {
     // TODO: parts of this should be moved out of TezSession to reuse the clients, but there's
     //       no good place for that right now (HIVE-13698).
+    // TODO: De-link from SessionState. A TezSession can be linked to different Hive Sessions
via the pool.
     SessionState session = SessionState.get();
     boolean isInHs2 = session != null && session.isHiveServerQuery();
     Token<LlapTokenIdentifier> token = null;
@@ -438,6 +439,7 @@ public class TezSessionState {
   private void setupSessionAcls(Configuration tezConf, HiveConf hiveConf) throws
       IOException {
 
+    // TODO: De-link from SessionState. A TezSession can be linked to different Hive Sessions
via the pool.
     String user = SessionState.getUserFromAuthenticator();
     UserGroupInformation loginUserUgi = UserGroupInformation.getLoginUser();
     String loginUser =
@@ -451,6 +453,7 @@ public class TezSessionState {
             TezConfiguration.TEZ_AM_MODIFY_ACLS, addHs2User, user, loginUser);
 
     if (LOG.isDebugEnabled()) {
+      // TODO: De-link from SessionState. A TezSession can be linked to different Hive Sessions
via the pool.
       LOG.debug(
           "Setting Tez Session access for sessionId={} with viewAclString={}, modifyStr={}",
           SessionState.get().getSessionId(), viewStr, modifyStr);
@@ -592,6 +595,7 @@ public class TezSessionState {
    */
   private Path createTezDir(String sessionId) throws IOException {
     // tez needs its own scratch dir (per session)
+    // TODO: De-link from SessionState. A TezSession can be linked to different Hive Sessions
via the pool.
     Path tezDir = new Path(SessionState.get().getHdfsScratchDirURIString(), TEZ_DIR);
     tezDir = new Path(tezDir, sessionId);
     FileSystem fs = tezDir.getFileSystem(conf);


Mime
View raw message