hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xu...@apache.org
Subject hive git commit: HIVE-17401: Hive session idle timeout doesn't function properly (Reviewed by Peter Vary)
Date Wed, 06 Sep 2017 17:06:17 GMT
Repository: hive
Updated Branches:
  refs/heads/master 9a5381cb9 -> 660e39e03


HIVE-17401: Hive session idle timeout doesn't function properly (Reviewed by Peter Vary)


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

Branch: refs/heads/master
Commit: 660e39e03b68f6d256a6d4fd41193503a1f711c9
Parents: 9a5381c
Author: Xuefu Zhang <xuefu@uber.com>
Authored: Wed Sep 6 10:06:01 2017 -0700
Committer: Xuefu Zhang <xuefu@uber.com>
Committed: Wed Sep 6 10:06:01 2017 -0700

----------------------------------------------------------------------
 .../service/cli/session/HiveSessionImpl.java    | 26 ++++++++------------
 1 file changed, 10 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/660e39e0/service/src/java/org/apache/hive/service/cli/session/HiveSessionImpl.java
----------------------------------------------------------------------
diff --git a/service/src/java/org/apache/hive/service/cli/session/HiveSessionImpl.java b/service/src/java/org/apache/hive/service/cli/session/HiveSessionImpl.java
index 57bb53c..906565c 100644
--- a/service/src/java/org/apache/hive/service/cli/session/HiveSessionImpl.java
+++ b/service/src/java/org/apache/hive/service/cli/session/HiveSessionImpl.java
@@ -111,9 +111,8 @@ public class HiveSessionImpl implements HiveSession {
   // TODO: the control flow for this needs to be defined. Hive is supposed to be thread-local.
   private Hive sessionHive;
 
-  private volatile long lastAccessTime;
-  private volatile long lastIdleTime;
-  private volatile int activeCalls = 0;
+  private volatile long lastAccessTime = System.currentTimeMillis();
+  private volatile boolean lockedByUser;
   private final Semaphore operationLock;
 
 
@@ -184,7 +183,6 @@ public class HiveSessionImpl implements HiveSession {
       configureSession(sessionConfMap);
     }
     lastAccessTime = System.currentTimeMillis();
-    lastIdleTime = lastAccessTime;
   }
 
 /**
@@ -384,12 +382,11 @@ public class HiveSessionImpl implements HiveSession {
     sessionState.setIsUsingThriftJDBCBinarySerDe(updateIsUsingThriftJDBCBinarySerDe());
     if (userAccess) {
       lastAccessTime = System.currentTimeMillis();
+      lockedByUser = true;
     }
     // set the thread name with the logging prefix.
     sessionState.updateThreadName();
     Hive.set(sessionHive);
-    activeCalls++;
-    lastIdleTime = 0;
   }
 
   /**
@@ -424,12 +421,7 @@ public class HiveSessionImpl implements HiveSession {
     }
     if (userAccess) {
       lastAccessTime = System.currentTimeMillis();
-    }
-    activeCalls--;
-    // lastIdleTime is only set by the last one
-    // who calls release with empty opHandleSet.
-    if (activeCalls == 0 && opHandleSet.isEmpty()) {
-      lastIdleTime = System.currentTimeMillis();
+      lockedByUser = false;
     }
   }
 
@@ -830,16 +822,18 @@ public class HiveSessionImpl implements HiveSession {
 
   @Override
   public long getNoOperationTime() {
-    return lastIdleTime > 0 ? System.currentTimeMillis() - lastIdleTime : 0;
+    boolean noMoreOpHandle = false;
+    synchronized (opHandleSet) {
+      noMoreOpHandle = opHandleSet.isEmpty();
+    }
+    return noMoreOpHandle && !lockedByUser ? System.currentTimeMillis() - lastAccessTime
: 0;
   }
 
   private void closeTimedOutOperations(List<Operation> operations) {
     acquire(false, false);
     try {
       for (Operation operation : operations) {
-        synchronized (opHandleSet) {
-          opHandleSet.remove(operation.getHandle());
-        }
+        removeOpHandle(operation.getHandle());
         try {
           operation.close();
         } catch (Exception e) {


Mime
View raw message