Repository: hive
Updated Branches:
  refs/heads/master 1a3e4be3d -> 3237bb276


HIVE-14774: Canceling query using Ctrl-C in beeline might lead to stale locks 
(Chaoyu Tang, reviewed by Jimmy Xiang, Mohit Sabharwal)


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

Branch: refs/heads/master
Commit: 3237bb276b79d2a54d0a5d8a5ede400147017618
Parents: 1a3e4be
Author: ctang <ct...@cloudera.com>
Authored: Thu Sep 22 14:47:47 2016 -0400
Committer: ctang <ct...@cloudera.com>
Committed: Thu Sep 22 14:47:47 2016 -0400

----------------------------------------------------------------------
 .../hive/service/cli/operation/SQLOperation.java  | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/3237bb27/service/src/java/org/apache/hive/service/cli/operation/SQLOperation.java
----------------------------------------------------------------------
diff --git 
a/service/src/java/org/apache/hive/service/cli/operation/SQLOperation.java 
b/service/src/java/org/apache/hive/service/cli/operation/SQLOperation.java
index 6f2daf3..abdf8cd 100644
--- a/service/src/java/org/apache/hive/service/cli/operation/SQLOperation.java
+++ b/service/src/java/org/apache/hive/service/cli/operation/SQLOperation.java
@@ -399,6 +399,17 @@ public class SQLOperation extends 
ExecuteStatementOperation {
 
   private synchronized void cleanup(OperationState state) throws 
HiveSQLException {
     setState(state);
+
+    if (shouldRunAsync()) {
+      Future<?> backgroundHandle = getBackgroundHandle();
+      if (backgroundHandle != null) {
+        boolean success = backgroundHandle.cancel(true);
+        if (success) {
+          LOG.info("The running operation has been successfully interrupted.");
+        }
+      }
+    }
+
     if (driver != null) {
       driver.close();
       driver.destroy();
@@ -413,13 +424,6 @@ public class SQLOperation extends 
ExecuteStatementOperation {
       ss.deleteTmpErrOutputFile();
     }
 
-    if (shouldRunAsync()) {
-      Future<?> backgroundHandle = getBackgroundHandle();
-      if (backgroundHandle != null) {
-        backgroundHandle.cancel(true);
-      }
-    }
-
     // Shutdown the timeout thread if any, while closing this operation
     if ((timeoutExecutor != null) && (state != OperationState.TIMEDOUT) && 
(state.isTerminal())) {
       timeoutExecutor.shutdownNow();

Reply via email to