Skip to content

Commit 1f01d81

Browse files
gengliangwangRobert Kruszewski
authored andcommitted
[SPARK-23838][WEBUI] Running SQL query is displayed as "completed" in SQL tab
## What changes were proposed in this pull request? A running SQL query would appear as completed in the Spark UI: ![image1](https://user-images.githubusercontent.com/1097932/38170733-3d7cb00c-35bf-11e8-994c-43f2d4fa285d.png) We can see the query in "Completed queries", while in in the job page we see it's still running Job 132. ![image2](https://user-images.githubusercontent.com/1097932/38170735-48f2c714-35bf-11e8-8a41-6fae23543c46.png) After some time in the query still appears in "Completed queries" (while it's still running), but the "Duration" gets increased. ![image3](https://user-images.githubusercontent.com/1097932/38170737-50f87ea4-35bf-11e8-8b60-000f6f918964.png) To reproduce, we can run a query with multiple jobs. E.g. Run TPCDS q6. The reason is that updates from executions are written into kvstore periodically, and the job start event may be missed. ## How was this patch tested? Manually run the job again and check the SQL Tab. The fix is pretty simple. Author: Gengliang Wang <[email protected]> Closes apache#20955 from gengliangwang/jobCompleted.
1 parent 5178d0c commit 1f01d81

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

sql/core/src/main/scala/org/apache/spark/sql/execution/ui/AllExecutionsPage.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ private[ui] class AllExecutionsPage(parent: SQLTab) extends WebUIPage("") with L
3939
val failed = new mutable.ArrayBuffer[SQLExecutionUIData]()
4040

4141
sqlStore.executionsList().foreach { e =>
42-
val isRunning = e.jobs.exists { case (_, status) => status == JobExecutionStatus.RUNNING }
42+
val isRunning = e.completionTime.isEmpty ||
43+
e.jobs.exists { case (_, status) => status == JobExecutionStatus.RUNNING }
4344
val isFailed = e.jobs.exists { case (_, status) => status == JobExecutionStatus.FAILED }
4445
if (isRunning) {
4546
running += e

sql/core/src/main/scala/org/apache/spark/sql/execution/ui/SQLAppStatusListener.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ class SQLAppStatusListener(
8888

8989
exec.jobs = exec.jobs + (jobId -> JobExecutionStatus.RUNNING)
9090
exec.stages ++= event.stageIds.toSet
91-
update(exec)
91+
update(exec, force = true)
9292
}
9393

9494
override def onStageSubmitted(event: SparkListenerStageSubmitted): Unit = {
@@ -308,11 +308,13 @@ class SQLAppStatusListener(
308308
})
309309
}
310310

311-
private def update(exec: LiveExecutionData): Unit = {
311+
private def update(exec: LiveExecutionData, force: Boolean = false): Unit = {
312312
val now = System.nanoTime()
313313
if (exec.endEvents >= exec.jobs.size + 1) {
314314
exec.write(kvstore, now)
315315
liveExecutions.remove(exec.executionId)
316+
} else if (force) {
317+
exec.write(kvstore, now)
316318
} else if (liveUpdatePeriodNs >= 0) {
317319
if (now - exec.lastWriteTime > liveUpdatePeriodNs) {
318320
exec.write(kvstore, now)

0 commit comments

Comments
 (0)