Repository: hive Updated Branches: refs/heads/master df3c5d059 -> 477a47d3b
HIVE-14296: Session count is not decremented when HS2 clients do not shutdown cleanly. (Naveen Gangam, reviewed by Szehon Ho and Mohit Sabharwal) Project: http://git-wip-us.apache.org/repos/asf/hive/repo Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/477a47d3 Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/477a47d3 Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/477a47d3 Branch: refs/heads/master Commit: 477a47d3b4b9e3da3c22465217c2024588f7f000 Parents: df3c5d0 Author: Aihua Xu <aihu...@apache.org> Authored: Wed Jul 27 16:08:34 2016 -0400 Committer: Aihua Xu <aihu...@apache.org> Committed: Wed Jul 27 16:08:34 2016 -0400 ---------------------------------------------------------------------- .../java/org/apache/hive/service/cli/session/SessionManager.java | 4 +++- .../org/apache/hive/service/cli/thrift/ThriftCLIService.java | 3 --- 2 files changed, 3 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hive/blob/477a47d3/service/src/java/org/apache/hive/service/cli/session/SessionManager.java ---------------------------------------------------------------------- diff --git a/service/src/java/org/apache/hive/service/cli/session/SessionManager.java b/service/src/java/org/apache/hive/service/cli/session/SessionManager.java index 4f5a852..88dee48 100644 --- a/service/src/java/org/apache/hive/service/cli/session/SessionManager.java +++ b/service/src/java/org/apache/hive/service/cli/session/SessionManager.java @@ -351,14 +351,16 @@ public class SessionManager extends CompositeService { throw new HiveSQLException("Failed to execute session hooks: " + e.getMessage(), e); } handleToSession.put(session.getSessionHandle(), session); + LOG.info("Session opened, " + session.getSessionHandle() + ", current sessions:" + getOpenSessionCount()); return session; } - public void closeSession(SessionHandle sessionHandle) throws HiveSQLException { + public synchronized void closeSession(SessionHandle sessionHandle) throws HiveSQLException { HiveSession session = handleToSession.remove(sessionHandle); if (session == null) { throw new HiveSQLException("Session does not exist: " + sessionHandle); } + LOG.info("Session closed, " + sessionHandle + ", current sessions:" + getOpenSessionCount()); try { session.close(); } finally { http://git-wip-us.apache.org/repos/asf/hive/blob/477a47d3/service/src/java/org/apache/hive/service/cli/thrift/ThriftCLIService.java ---------------------------------------------------------------------- diff --git a/service/src/java/org/apache/hive/service/cli/thrift/ThriftCLIService.java b/service/src/java/org/apache/hive/service/cli/thrift/ThriftCLIService.java index 0dd56cb..886492a 100644 --- a/service/src/java/org/apache/hive/service/cli/thrift/ThriftCLIService.java +++ b/service/src/java/org/apache/hive/service/cli/thrift/ThriftCLIService.java @@ -117,7 +117,6 @@ public abstract class ThriftCLIService extends AbstractService implements TCLISe protected CLIService cliService; private static final TStatus OK_STATUS = new TStatus(TStatusCode.SUCCESS_STATUS); protected static HiveAuthFactory hiveAuthFactory; - private static final AtomicInteger sessionCount = new AtomicInteger(); protected int portNum; protected InetAddress serverIPAddress; @@ -320,7 +319,6 @@ public abstract class ThriftCLIService extends AbstractService implements TCLISe if (context != null) { context.setSessionHandle(sessionHandle); } - LOG.info("Opened a session " + sessionHandle + ", current sessions: " + sessionCount.incrementAndGet()); } catch (Exception e) { LOG.warn("Error opening session: ", e); resp.setStatus(HiveSQLException.toTStatus(e)); @@ -466,7 +464,6 @@ public abstract class ThriftCLIService extends AbstractService implements TCLISe try { SessionHandle sessionHandle = new SessionHandle(req.getSessionHandle()); cliService.closeSession(sessionHandle); - LOG.info("Closed a session " + sessionHandle + ", current sessions: " + sessionCount.decrementAndGet()); resp.setStatus(OK_STATUS); ThriftCLIServerContext context = (ThriftCLIServerContext)currentServerContext.get();