diff --git beeline/src/java/org/apache/hive/beeline/Commands.java beeline/src/java/org/apache/hive/beeline/Commands.java index 6a3ad42..609e85f 100644 --- beeline/src/java/org/apache/hive/beeline/Commands.java +++ beeline/src/java/org/apache/hive/beeline/Commands.java @@ -1292,16 +1292,25 @@ private void updateQueryLog() throws SQLException { } } + private void showRemainingLogsIfAny() { + commands.debug("Getting log thread is interrupted, since query is done!"); + commands.showRemainingLogsIfAny(hiveStatement); + } + @Override public void run() { while (hiveStatement.hasMoreLogs()) { try { + if (Thread.currentThread().isInterrupted()) { + showRemainingLogsIfAny(); + break; + } updateQueryLog(); Thread.sleep(queryProgressInterval); } catch (SQLException e) { commands.error(new SQLWarning(e)); } catch (InterruptedException e) { - commands.debug("Getting log thread is interrupted, since query is done!"); - commands.showRemainingLogsIfAny(hiveStatement); + showRemainingLogsIfAny(); + break; } } } diff --git jdbc/src/java/org/apache/hive/jdbc/HiveStatement.java jdbc/src/java/org/apache/hive/jdbc/HiveStatement.java index c846a76..5ab6c90 100644 --- jdbc/src/java/org/apache/hive/jdbc/HiveStatement.java +++ jdbc/src/java/org/apache/hive/jdbc/HiveStatement.java @@ -315,9 +315,11 @@ private void runAsyncOnServer(String sql) throws SQLException { isExecuteStatementFailed = false; } catch (SQLException eS) { isExecuteStatementFailed = true; + isLogBeingGenerated = false; throw eS; } catch (Exception ex) { isExecuteStatementFailed = true; + isLogBeingGenerated = false; throw new SQLException(ex.toString(), "08S01", ex); } }