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:29 GMT
Repository: hive
Updated Branches:
  refs/heads/branch-1.0 b56623b18 -> a7a96afb9


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/a7a96afb
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/a7a96afb
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/a7a96afb

Branch: refs/heads/branch-1.0
Commit: a7a96afb9651a5e0fa01fcef05ab61ff8c1917c2
Parents: b56623b
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:24 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/a7a96afb/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 7206a1d..e8dab75 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
@@ -152,11 +152,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/a7a96afb/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 37b698b..aa38a66 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