hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From the...@apache.org
Subject svn commit: r1586495 - /hive/trunk/service/src/java/org/apache/hive/service/cli/operation/SQLOperation.java
Date Thu, 10 Apr 2014 22:36:53 GMT
Author: thejas
Date: Thu Apr 10 22:36:52 2014
New Revision: 1586495

URL: http://svn.apache.org/r1586495
Log:
HIVE-6864 : HiveServer2 concurrency uses incorrect user information in unsecured mode (Vaibhav
Gumashta via Thejas Nair)

Modified:
    hive/trunk/service/src/java/org/apache/hive/service/cli/operation/SQLOperation.java

Modified: hive/trunk/service/src/java/org/apache/hive/service/cli/operation/SQLOperation.java
URL: http://svn.apache.org/viewvc/hive/trunk/service/src/java/org/apache/hive/service/cli/operation/SQLOperation.java?rev=1586495&r1=1586494&r2=1586495&view=diff
==============================================================================
--- hive/trunk/service/src/java/org/apache/hive/service/cli/operation/SQLOperation.java (original)
+++ hive/trunk/service/src/java/org/apache/hive/service/cli/operation/SQLOperation.java Thu
Apr 10 22:36:52 2014
@@ -36,6 +36,8 @@ import org.apache.hadoop.hive.ql.Command
 import org.apache.hadoop.hive.ql.Driver;
 import org.apache.hadoop.hive.ql.exec.ExplainTask;
 import org.apache.hadoop.hive.ql.exec.Task;
+import org.apache.hadoop.hive.ql.metadata.Hive;
+import org.apache.hadoop.hive.ql.metadata.HiveException;
 import org.apache.hadoop.hive.ql.parse.VariableSubstitution;
 import org.apache.hadoop.hive.ql.processors.CommandProcessorResponse;
 import org.apache.hadoop.hive.ql.session.SessionState;
@@ -167,11 +169,17 @@ public class SQLOperation extends Execut
     if (!shouldRunAsync()) {
       runInternal(getConfigForOperation());
     } else {
+      final SessionState parentSessionState = SessionState.get();
+      final Hive sessionHive = getCurrentHive();
+      // Runnable impl to call runInternal asynchronously,
+      // from a different thread
       Runnable backgroundOperation = new Runnable() {
-        SessionState ss = SessionState.get();
         @Override
         public void run() {
-          SessionState.setCurrentSessionState(ss);
+          // Storing the current Hive object necessary when doAs is enabled
+          // User information is part of the metastore client member in Hive
+          Hive.set(sessionHive);
+          SessionState.setCurrentSessionState(parentSessionState);
           try {
             runInternal(getConfigForOperation());
           } catch (HiveSQLException e) {
@@ -187,12 +195,20 @@ public class SQLOperation extends Execut
         setBackgroundHandle(backgroundHandle);
       } catch (RejectedExecutionException rejected) {
         setState(OperationState.ERROR);
-        throw new HiveSQLException("All the asynchronous threads are currently busy, " +
-            "please retry the operation", rejected);
+        throw new HiveSQLException("The background threadpool cannot accept" +
+            " new task for execution, please retry the operation", rejected);
       }
     }
   }
 
+  private Hive getCurrentHive() throws HiveSQLException {
+    try {
+      return Hive.get();
+    } catch (HiveException e) {
+      throw new HiveSQLException("Failed to get current Hive object", e);
+    }
+  }
+
   private void cleanup(OperationState state) throws HiveSQLException {
     setState(state);
     if (shouldRunAsync()) {



Mime
View raw message