Repository: hive Updated Branches: refs/heads/branch-2.1 cfa5e928c -> 0c5b1bff6
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/0c5b1bff Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/0c5b1bff Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/0c5b1bff Branch: refs/heads/branch-2.1 Commit: 0c5b1bff6c8295f5c49b94a28e25ef379a2cf196 Parents: cfa5e92 Author: ctang <ct...@cloudera.com> Authored: Thu Sep 22 14:47:47 2016 -0400 Committer: ctang <ct...@cloudera.com> Committed: Thu Sep 22 14:48:31 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/0c5b1bff/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 3df831c..c25196b 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 @@ -393,6 +393,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(); @@ -407,13 +418,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();