-
Notifications
You must be signed in to change notification settings - Fork 29.3k
[SPARK-33526][SQL] Add config to control if cancel invoke interrupt task on thriftserver #30481
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
Changes from 4 commits
9b54da6
ba382a3
911da70
d1ebbba
de89232
9a05f0b
f8d6384
cd54e48
c9c5cd3
921f9cf
99ec864
0466c0c
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 |
|---|---|---|
|
|
@@ -937,6 +937,16 @@ object SQLConf { | |
| .timeConf(TimeUnit.SECONDS) | ||
| .createWithDefault(0L) | ||
|
|
||
| val THRIFTSERVER_FORCE_CANCEL = | ||
| buildConf("spark.sql.thriftServer.forceCancel") | ||
|
Member
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 is actually to set
Contributor
Author
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. Sounds good. |
||
| .doc("When true, all the job of query will be cancelled and running tasks will be" + | ||
| "interrupted. When false, all the job of query will be cancelled but running task" + | ||
| "will be remained until finished. Note that, this config must be set before query" + | ||
| "otherwise it doesn't help.") | ||
|
Member
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. We need to describe
Contributor
Author
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. Removed. |
||
| .version("3.2.0") | ||
| .booleanConf | ||
| .createWithDefault(false) | ||
|
Contributor
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 wasn't aware that cancelling a job group leaves currently running tasks running to completion.
Contributor
Author
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 reason is same with |
||
|
|
||
| val THRIFTSERVER_UI_STATEMENT_LIMIT = | ||
| buildConf("spark.sql.thriftserver.ui.retainedStatements") | ||
| .doc("The number of SQL statements kept in the JDBC/ODBC web UI history.") | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,9 +18,14 @@ | |
| package org.apache.spark.sql.hive.thriftserver | ||
|
|
||
| import java.sql.SQLException | ||
| import java.util.concurrent.atomic.AtomicBoolean | ||
|
|
||
| import org.apache.hive.service.cli.HiveSQLException | ||
|
|
||
| import org.apache.spark.TaskKilled | ||
| import org.apache.spark.scheduler.{SparkListener, SparkListenerTaskEnd} | ||
| import org.apache.spark.sql.internal.SQLConf | ||
|
|
||
| trait ThriftServerWithSparkContextSuite extends SharedThriftServer { | ||
|
|
||
| test("the scratch dir will be deleted during server start but recreated with new operation") { | ||
|
|
@@ -79,6 +84,45 @@ trait ThriftServerWithSparkContextSuite extends SharedThriftServer { | |
| "java.lang.NumberFormatException: invalid input syntax for type numeric: 1.2")) | ||
| } | ||
| } | ||
|
|
||
| test("SPARK-33526: Add config to control if cancel invoke interrupt task on thriftserver") { | ||
| withJdbcStatement { statement => | ||
| val forceCancel = new AtomicBoolean(false) | ||
| val listener = new SparkListener { | ||
| override def onTaskEnd(taskEnd: SparkListenerTaskEnd): Unit = { | ||
| taskEnd.reason match { | ||
| case _: TaskKilled => | ||
| if (forceCancel.get()) { | ||
| assert(System.currentTimeMillis() - taskEnd.taskInfo.launchTime < 1000) | ||
| } else { | ||
| assert(System.currentTimeMillis() - taskEnd.taskInfo.launchTime >= 2000) | ||
| } | ||
| case _ => | ||
|
Member
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 add
Contributor
Author
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. Updated. |
||
| } | ||
| } | ||
| } | ||
|
|
||
| spark.sparkContext.addSparkListener(listener) | ||
| try { | ||
| statement.execute(s"SET ${SQLConf.THRIFTSERVER_QUERY_TIMEOUT.key}=1") | ||
| statement.execute(s"SET ${SQLConf.THRIFTSERVER_FORCE_CANCEL.key}=false") | ||
| forceCancel.set(false) | ||
| val e1 = intercept[SQLException] { | ||
| statement.execute("select java_method('java.lang.Thread', 'sleep', 3000L)") | ||
| }.getMessage | ||
| assert(e1.contains("Query timed out")) | ||
|
|
||
| statement.execute(s"SET ${SQLConf.THRIFTSERVER_FORCE_CANCEL.key}=true") | ||
| forceCancel.set(true) | ||
| val e2 = intercept[SQLException] { | ||
| statement.execute("select java_method('java.lang.Thread', 'sleep', 3000L)") | ||
| }.getMessage | ||
| assert(e2.contains("Query timed out")) | ||
|
Member
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 codes in L105-111 and L113-118 seems to be almost the same, so could you write it like this?
Contributor
Author
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. Looks better ! |
||
| } finally { | ||
| spark.sparkContext.removeSparkListener(listener) | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
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.
thriftServer? thriftserver?
spark.sql.thriftserver.scheduler.poolspark.sql.thriftserver.ui.retainedStatementsspark.sql.thriftserver.ui.retainedSessionsspark.sql.thriftServer.queryTimeoutspark.sql.thriftServer.incrementalCollectThere 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.
Seems recent config names
thriftServer.thriftserveris early version config.