You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by yc...@apache.org on 2017/05/09 14:26:31 UTC

hive git commit: HIVE-16451: Race condition between HiveStatement.getQueryLog and HiveStatement.runAsyncOnServer (Peter Vary, reviewed by Anishek and Yongzhi Chen)

Repository: hive
Updated Branches:
  refs/heads/master f3310a37b -> 691acd5a3


HIVE-16451: Race condition between HiveStatement.getQueryLog and HiveStatement.runAsyncOnServer (Peter Vary, reviewed by Anishek and Yongzhi Chen)


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

Branch: refs/heads/master
Commit: 691acd5a3a0948c7c8fb956b6a72c9afb780e270
Parents: f3310a3
Author: Yongzhi Chen <yc...@apache.org>
Authored: Tue May 9 10:23:15 2017 -0400
Committer: Yongzhi Chen <yc...@apache.org>
Committed: Tue May 9 10:23:15 2017 -0400

----------------------------------------------------------------------
 .../org/apache/hive/jdbc/HiveStatement.java     | 21 ++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/691acd5a/jdbc/src/java/org/apache/hive/jdbc/HiveStatement.java
----------------------------------------------------------------------
diff --git a/jdbc/src/java/org/apache/hive/jdbc/HiveStatement.java b/jdbc/src/java/org/apache/hive/jdbc/HiveStatement.java
index c385e2c..b743b46 100644
--- a/jdbc/src/java/org/apache/hive/jdbc/HiveStatement.java
+++ b/jdbc/src/java/org/apache/hive/jdbc/HiveStatement.java
@@ -201,18 +201,27 @@ public class HiveStatement implements java.sql.Statement {
     warningChain = null;
   }
 
-  void closeClientOperation() throws SQLException {
+  /**
+   * Closes the statement if there is one running. Do not change the the flags.
+   * @throws SQLException If there is an error closing the statement
+   */
+  private void closeStatementIfNeeded() throws SQLException {
     try {
       if (stmtHandle != null) {
         TCloseOperationReq closeReq = new TCloseOperationReq(stmtHandle);
         TCloseOperationResp closeResp = client.CloseOperation(closeReq);
         Utils.verifySuccessWithInfo(closeResp.getStatus());
+        stmtHandle = null;
       }
     } catch (SQLException e) {
       throw e;
     } catch (Exception e) {
       throw new SQLException(e.toString(), "08S01", e);
     }
+  }
+
+  void closeClientOperation() throws SQLException {
+    closeStatementIfNeeded();
     isQueryClosed = true;
     isExecuteStatementFailed = false;
     stmtHandle = null;
@@ -295,8 +304,7 @@ public class HiveStatement implements java.sql.Statement {
   private void runAsyncOnServer(String sql) throws SQLException {
     checkConnection("execute");
 
-    closeClientOperation();
-    initFlags();
+    reInitState();
 
     TExecuteStatementReq execReq = new TExecuteStatementReq(sessHandle, sql);
     /**
@@ -413,7 +421,12 @@ public class HiveStatement implements java.sql.Statement {
     }
   }
 
-  private void initFlags() {
+  /**
+   * Close statement if needed, and reset the flags.
+   * @throws SQLException
+   */
+  private void reInitState() throws SQLException {
+    closeStatementIfNeeded();
     isCancelled = false;
     isQueryClosed = false;
     isLogBeingGenerated = true;