Skip to content

Commit b37e76f

Browse files
author
Marcelo Vanzin
committed
[SPARK-24414][UI] Calculate the correct number of tasks for a stage.
This change takes into account all non-pending tasks when calculating the number of tasks to be shown. This also means that when the stage is pending, the task table (or, in fact, most of the data in the stage page) will not be rendered. I also fixed the label when the known number of tasks is larger than the recorded number of tasks (it was inverted). Author: Marcelo Vanzin <[email protected]> Closes #21457 from vanzin/SPARK-24414. (cherry picked from commit 7a82e93) Signed-off-by: Marcelo Vanzin <[email protected]>
1 parent dc24da2 commit b37e76f

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

core/src/main/scala/org/apache/spark/ui/jobs/StagePage.scala

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,7 @@ private[ui] class StagePage(parent: StagesTab, store: AppStatusStore) extends We
117117

118118
val localitySummary = store.localitySummary(stageData.stageId, stageData.attemptId)
119119

120-
val totalTasks = stageData.numActiveTasks + stageData.numCompleteTasks +
121-
stageData.numFailedTasks + stageData.numKilledTasks
120+
val totalTasks = taskCount(stageData)
122121
if (totalTasks == 0) {
123122
val content =
124123
<div>
@@ -133,7 +132,7 @@ private[ui] class StagePage(parent: StagesTab, store: AppStatusStore) extends We
133132
val totalTasksNumStr = if (totalTasks == storedTasks) {
134133
s"$totalTasks"
135134
} else {
136-
s"$totalTasks, showing ${storedTasks}"
135+
s"$storedTasks, showing ${totalTasks}"
137136
}
138137

139138
val summary =
@@ -678,7 +677,7 @@ private[ui] class TaskDataSource(
678677

679678
private var _tasksToShow: Seq[TaskData] = null
680679

681-
override def dataSize: Int = stage.numTasks
680+
override def dataSize: Int = taskCount(stage)
682681

683682
override def sliceData(from: Int, to: Int): Seq[TaskData] = {
684683
if (_tasksToShow == null) {
@@ -1044,4 +1043,9 @@ private[ui] object ApiHelper {
10441043
(stage.map(_.name).getOrElse(""), stage.flatMap(_.description).getOrElse(job.name))
10451044
}
10461045

1046+
def taskCount(stageData: StageData): Int = {
1047+
stageData.numActiveTasks + stageData.numCompleteTasks + stageData.numFailedTasks +
1048+
stageData.numKilledTasks
1049+
}
1050+
10471051
}

0 commit comments

Comments
 (0)