vanzin commented on a change in pull request #27002: [SPARK-30346][CORE]Improve 
logging when events dropped
URL: https://github.com/apache/spark/pull/27002#discussion_r363990881
 
 

 ##########
 File path: core/src/main/scala/org/apache/spark/scheduler/AsyncEventQueue.scala
 ##########
 @@ -167,20 +170,27 @@ private class AsyncEventQueue(
     }
     logTrace(s"Dropping event $event")
 
-    val droppedCount = droppedEventsCounter.get
+    val droppedCount = droppedEventsCounter.get - lastDroppedEventsCounter
+    val lastReportTime = lastReportTimestamp.get
+    val curTime = System.currentTimeMillis()
     if (droppedCount > 0) {
       // Don't log too frequently
-      if (System.currentTimeMillis() - lastReportTimestamp >= 60 * 1000) {
-        // There may be multiple threads trying to decrease 
droppedEventsCounter.
-        // Use "compareAndSet" to make sure only one thread can win.
-        // And if another thread is increasing droppedEventsCounter, 
"compareAndSet" will fail and
-        // then that thread will update it.
-        if (droppedEventsCounter.compareAndSet(droppedCount, 0)) {
-          val prevLastReportTimestamp = lastReportTimestamp
-          lastReportTimestamp = System.currentTimeMillis()
-          val previous = new java.util.Date(prevLastReportTimestamp)
+      if (curTime - lastReportTime >= LOGGING_INTERVAL) {
+        // There may be multiple threads trying to logging dropped events,
+        // Use 'compareAndSet' to make sure only one thread can win.
+        if (lastReportTimestamp.compareAndSet(lastReportTime, curTime)) {
+          val lastReportTime = lastReportTimestamp.get
+          val previous = new java.util.Date(lastReportTime)
+          lastDroppedEventsCounter = droppedCount
           logWarning(s"Dropped $droppedCount events from $name since " +
-            s"${if (prevLastReportTimestamp == 0) "the application started" 
else s"$previous"}.")
+            s"${if (lastReportTime == 0) "the application started" else 
s"$previous"}.")
+          // Logging thread dump when events from appStatus was dropped
+          Utils.getThreadDumpForThread(dispatchThread.getId).foreach { thread 
=>
+            if (thread.threadName.contains(LiveListenerBus.APP_STATUS_QUEUE)) {
+              logWarning(s"Event dropped!!!Thread dump from dispatch thread " +
 
 Review comment:
   If you want to keep this I'd demote it from warning to info or even debug. 
The separate functionality to measure each event's processing time is really 
the better option for debugging things here.
   
   (And also, in that case, gate the whole block with e.g. 
`log.isDebugEnabled`.)

----------------------------------------------------------------
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]


With regards,
Apache Git Services

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

Reply via email to