Repository: hive Updated Branches: refs/heads/master 7766d5cad -> 8584b8b7f
HIVE-13960: Session may timeout before idle timeout time for synchronous operations (Zhihai Xu via Jimmy Xiang) Project: http://git-wip-us.apache.org/repos/asf/hive/repo Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/8584b8b7 Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/8584b8b7 Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/8584b8b7 Branch: refs/heads/master Commit: 8584b8b7f7529016b528e68f7802886ab02742df Parents: 7766d5c Author: Jimmy Xiang <jxi...@apache.org> Authored: Sat Jun 11 09:02:45 2016 -0700 Committer: Jimmy Xiang <jxi...@apache.org> Committed: Sat Jun 11 09:03:37 2016 -0700 ---------------------------------------------------------------------- .../apache/hive/service/cli/session/HiveSessionImpl.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hive/blob/8584b8b7/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 54ee567..7341635 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 @@ -113,6 +113,7 @@ public class HiveSessionImpl implements HiveSession { private volatile long lastAccessTime; private volatile long lastIdleTime; + private volatile int pendingCount = 0; public HiveSessionImpl(SessionHandle sessionHandle, TProtocolVersion protocol, String username, String password, @@ -336,6 +337,8 @@ public class HiveSessionImpl implements HiveSession { // set the thread name with the logging prefix. sessionState.updateThreadName(); Hive.set(sessionHive); + pendingCount++; + lastIdleTime = 0; } /** @@ -361,10 +364,11 @@ public class HiveSessionImpl implements HiveSession { if (userAccess) { lastAccessTime = System.currentTimeMillis(); } - if (opHandleSet.isEmpty()) { + pendingCount--; + // lastIdleTime is only set by the last one + // who calls release with empty opHandleSet. + if (pendingCount == 0 && opHandleSet.isEmpty()) { lastIdleTime = System.currentTimeMillis(); - } else { - lastIdleTime = 0; } }