hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From the...@apache.org
Subject hive git commit: HIVE-12660 : HS2 memory leak with .hiverc file use (Thejas Nair, reviewed by Vaibhav Gumashta, Dong Chen)
Date Mon, 11 Jan 2016 17:41:04 GMT
Repository: hive
Updated Branches:
  refs/heads/branch-2.0 5bcfe4d74 -> abe594ec7


HIVE-12660 : HS2 memory leak with .hiverc file use (Thejas Nair, reviewed by Vaibhav Gumashta,
Dong Chen)


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

Branch: refs/heads/branch-2.0
Commit: abe594ec73178cf68cf31ea2435289b4b1545d98
Parents: 5bcfe4d
Author: Thejas Nair <thejas@hortonworks.com>
Authored: Mon Jan 11 09:40:26 2016 -0800
Committer: Thejas Nair <thejas@hortonworks.com>
Committed: Mon Jan 11 09:41:00 2016 -0800

----------------------------------------------------------------------
 .../hive/service/cli/session/HiveSessionImpl.java  | 15 ++++++++++++---
 .../cli/session/TestSessionGlobalInitFile.java     | 17 ++++++++++++++---
 2 files changed, 26 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/abe594ec/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 50c912e..b1b1d8f 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
@@ -192,11 +192,20 @@ public class HiveSessionImpl implements HiveSession {
     protected int processCmd(String cmd) {
       int rc = 0;
       String cmd_trimed = cmd.trim();
+      OperationHandle opHandle = null;
       try {
-        executeStatementInternal(cmd_trimed, null, false);
+        //execute in sync mode
+        opHandle = executeStatementInternal(cmd_trimed, null, false);
       } catch (HiveSQLException e) {
-        rc = -1;
-        LOG.warn("Failed to execute HQL command in global .hiverc file.", e);
+        LOG.warn("Failed to execute command in global .hiverc file.", e);
+        return -1;
+      }
+      if (opHandle != null) {
+        try {
+          closeOperation(opHandle);
+        } catch (HiveSQLException e) {
+          LOG.warn("Failed to close operation for command in .hiverc file.", e);
+        }
       }
       return rc;
     }

http://git-wip-us.apache.org/repos/asf/hive/blob/abe594ec/service/src/test/org/apache/hive/service/cli/session/TestSessionGlobalInitFile.java
----------------------------------------------------------------------
diff --git a/service/src/test/org/apache/hive/service/cli/session/TestSessionGlobalInitFile.java
b/service/src/test/org/apache/hive/service/cli/session/TestSessionGlobalInitFile.java
index 840a551..55a325d 100644
--- a/service/src/test/org/apache/hive/service/cli/session/TestSessionGlobalInitFile.java
+++ b/service/src/test/org/apache/hive/service/cli/session/TestSessionGlobalInitFile.java
@@ -22,19 +22,19 @@ import java.util.Arrays;
 import java.util.HashMap;
 import java.util.Map;
 
-import junit.framework.Assert;
 import junit.framework.TestCase;
 
 import org.apache.commons.io.FileUtils;
 import org.apache.hadoop.hive.conf.HiveConf;
 import org.apache.hive.service.cli.CLIService;
-import org.apache.hive.service.cli.ICLIService;
 import org.apache.hive.service.cli.OperationHandle;
 import org.apache.hive.service.cli.RowSet;
 import org.apache.hive.service.cli.SessionHandle;
+import org.apache.hive.service.cli.operation.OperationManager;
 import org.apache.hive.service.cli.thrift.ThriftBinaryCLIService;
 import org.apache.hive.service.cli.thrift.ThriftCLIServiceClient;
 import org.junit.After;
+import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -58,7 +58,7 @@ public class TestSessionGlobalInitFile extends TestCase {
       cliService.start();
     }
 
-    public ICLIService getService() {
+    public CLIService getService() {
       return cliService;
     }
   }
@@ -123,8 +123,15 @@ public class TestSessionGlobalInitFile extends TestCase {
    * setting property.
    */
   private void doTestSessionGlobalInitFile() throws Exception {
+
+    OperationManager operationManager = service.getService().getSessionManager()
+        .getOperationManager();
     SessionHandle sessionHandle = client.openSession(null, null, null);
 
+    // ensure there is no operation related object leak
+    Assert.assertEquals("Verifying all operations used for init file are closed",
+        0, operationManager.getOperations().size());
+
     verifyInitProperty("a", "1", sessionHandle);
     verifyInitProperty("b", "1", sessionHandle);
     verifyInitProperty("c", "1", sessionHandle);
@@ -137,7 +144,10 @@ public class TestSessionGlobalInitFile extends TestCase {
      */
     // Assert.assertEquals("expected uri", api.getAddedResource("jar"));
 
+    Assert.assertEquals("Verifying all operations used for checks are closed",
+        0, operationManager.getOperations().size());
     client.closeSession(sessionHandle);
+
   }
 
   @Test
@@ -175,5 +185,6 @@ public class TestSessionGlobalInitFile extends TestCase {
     Assert.assertEquals(1, rowSet.numRows());
     // we know rowSet has only one element
     Assert.assertEquals(key + "=" + value, rowSet.iterator().next()[0]);
+    client.closeOperation(operationHandle);
   }
 }


Mime
View raw message