sarutak commented on a change in pull request #29082:
URL: https://github.com/apache/spark/pull/29082#discussion_r470297451



##########
File path: core/src/main/scala/org/apache/spark/status/AppStatusStore.scala
##########
@@ -421,6 +420,51 @@ private[spark] class AppStatusStore(
     constructTaskDataList(taskDataWrapperIter)
   }
 
+  def exceptionSummary(stageId: Int, attemptId: Int): Seq[v1.ExceptionSummary] 
= {
+    val (stageData, _) = stageAttempt(stageId, attemptId)
+    val key = Array(stageId, attemptId, stageData.numFailedTasks)
+    asOption(store.read(classOf[CachedExceptionSummary], key))
+      .map(_.exceptionSummary)
+      .getOrElse {
+        val exceptionSummary = computeExceptionSummary(stageId, attemptId)
+        val cachedExceptionSummary = new CachedExceptionSummary(
+          stageId,
+          attemptId,
+          stageData.numFailedTasks,
+          exceptionSummary
+        )
+        store.write(cachedExceptionSummary)
+        exceptionSummary
+      }
+  }
+
+  def computeExceptionSummary(stageId: Int, attemptId: Int): 
Seq[v1.ExceptionSummary] = {
+    val tasks = taskList(stageId, attemptId, Int.MaxValue)
+    tasks.filter(t => t.status.equalsIgnoreCase("failed"))
+      .flatMap(t => t.errorMessage)
+      .flatMap(parseErrorMessage)
+      .groupBy(e => (e.exceptionType, e.message))
+      .map(t => new v1.ExceptionSummary(t._2.head, t._2.length))
+      .toSeq
+      .sortBy(s => (s.count, s.exceptionFailure.exceptionType))(Ordering[(Int, 
String)].reverse)
+      .take(10)

Review comment:
       It would be better to have `10` as a named constant.

##########
File path: core/src/main/scala/org/apache/spark/status/AppStatusStore.scala
##########
@@ -421,6 +420,33 @@ private[spark] class AppStatusStore(
     constructTaskDataList(taskDataWrapperIter)
   }
 
+  def exceptionSummary(stageId: Int, attemptId: Int): Seq[v1.ExceptionSummary] 
= {
+    val tasks = taskList(stageId, attemptId, Int.MaxValue)

Review comment:
       `CachedExceptionSummary` seems to never be deleted. This would be a 
potential cause of memory leak?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to