New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SPARK-26533][SQL][test-hadoop2.7] Support query auto timeout cancel on thriftserver #28991
Changes from all commits
75fe12f
5dc76c6
7e7ea7e
e352fcd
e0d97c5
217249d
4ca75ba
da76e1a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -874,6 +874,35 @@ class HiveThriftBinaryServerSuite extends HiveThriftJdbcTest { | |
assert(rs.getString(1) === expected.toString) | ||
} | ||
} | ||
|
||
test("SPARK-26533: Support query auto timeout cancel on thriftserver") { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you check if it can throw an exception (when hive1.2 used internally) by using
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed, thanks |
||
withJdbcStatement() { statement => | ||
if (HiveUtils.isHive23) { | ||
statement.setQueryTimeout(1) | ||
val e = intercept[SQLException] { | ||
statement.execute("select java_method('java.lang.Thread', 'sleep', 3000L)") | ||
}.getMessage | ||
assert(e.contains("Query timed out after")) | ||
|
||
statement.setQueryTimeout(0) | ||
val rs1 = statement.executeQuery( | ||
"select 'test', java_method('java.lang.Thread', 'sleep', 3000L)") | ||
rs1.next() | ||
assert(rs1.getString(1) == "test") | ||
|
||
statement.setQueryTimeout(-1) | ||
val rs2 = statement.executeQuery( | ||
"select 'test', java_method('java.lang.Thread', 'sleep', 3000L)") | ||
rs2.next() | ||
assert(rs2.getString(1) == "test") | ||
} else { | ||
val e = intercept[SQLException] { | ||
statement.setQueryTimeout(1) | ||
}.getMessage | ||
assert(e.contains("Method not supported")) | ||
} | ||
} | ||
} | ||
} | ||
|
||
class SingleSessionSuite extends HiveThriftJdbcTest { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,7 +32,8 @@ public enum OperationState { | |
CLOSED(TOperationState.CLOSED_STATE, true), | ||
ERROR(TOperationState.ERROR_STATE, true), | ||
UNKNOWN(TOperationState.UKNOWN_STATE, false), | ||
PENDING(TOperationState.PENDING_STATE, false); | ||
PENDING(TOperationState.PENDING_STATE, false), | ||
TIMEDOUT(TOperationState.CANCELED_STATE, true); //do not want to change TOperationState in hive 1.2 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What does There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The class of TOperationState was generated by thift, so we should not change it directly There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will not work and never be used with hive-1.2 anyway, because it's not in HIVE_CLI_SERVICE_PROTOCOL_V8. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. Only |
||
|
||
private final TOperationState tOperationState; | ||
private final boolean terminal; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -87,7 +87,7 @@ private void initOperationLogCapture(String loggingMode) { | |
} | ||
|
||
public ExecuteStatementOperation newExecuteStatementOperation(HiveSession parentSession, | ||
String statement, Map<String, String> confOverlay, boolean runAsync) | ||
String statement, Map<String, String> confOverlay, boolean runAsync, long queryTimeout) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we change these at all since There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This update is needed to add the |
||
throws HiveSQLException { | ||
ExecuteStatementOperation executeStatementOperation = ExecuteStatementOperation | ||
.newExecuteStatementOperation(parentSession, statement, confOverlay, runAsync); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -86,20 +86,15 @@ private void initOperationLogCapture(String loggingMode) { | |
} | ||
|
||
public ExecuteStatementOperation newExecuteStatementOperation(HiveSession parentSession, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do you need to replace the previous methods here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this update is just to pass |
||
String statement, Map<String, String> confOverlay, boolean runAsync) | ||
throws HiveSQLException { | ||
ExecuteStatementOperation executeStatementOperation = ExecuteStatementOperation | ||
.newExecuteStatementOperation(parentSession, statement, confOverlay, runAsync, 0); | ||
String statement, Map<String, String> confOverlay, boolean runAsync, long queryTimeout) | ||
throws HiveSQLException { | ||
ExecuteStatementOperation executeStatementOperation = | ||
ExecuteStatementOperation.newExecuteStatementOperation(parentSession, statement, | ||
confOverlay, runAsync, queryTimeout); | ||
addOperation(executeStatementOperation); | ||
return executeStatementOperation; | ||
} | ||
|
||
public ExecuteStatementOperation newExecuteStatementOperation(HiveSession parentSession, | ||
String statement, Map<String, String> confOverlay, boolean runAsync, long queryTimeout) | ||
throws HiveSQLException { | ||
return newExecuteStatementOperation(parentSession, statement, confOverlay, runAsync); | ||
} | ||
|
||
public GetTypeInfoOperation newGetTypeInfoOperation(HiveSession parentSession) { | ||
GetTypeInfoOperation operation = new GetTypeInfoOperation(parentSession); | ||
addOperation(operation); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:
logInfo
is located just beforeHiveThriftServer2.eventManager.onXXX
?spark/sql/hive-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/SparkOperation.scala
Lines 51 to 52 in 42f01e3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks, fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please setState before cleanup. It's an open bug, see #28912
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea, nice suggestion! Might be better to add tests for that case, too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed, thanks for your review