-
Notifications
You must be signed in to change notification settings - Fork 29.3k
[SPARK-17649][Core]Log how many Spark events got dropped in LiveListenerBus #15220
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 1 commit
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 |
|---|---|---|
|
|
@@ -18,7 +18,7 @@ | |
| package org.apache.spark.scheduler | ||
|
|
||
| import java.util.concurrent._ | ||
| import java.util.concurrent.atomic.AtomicBoolean | ||
| import java.util.concurrent.atomic.{AtomicBoolean, AtomicLong} | ||
|
|
||
| import scala.util.DynamicVariable | ||
|
|
||
|
|
@@ -57,6 +57,12 @@ private[spark] class LiveListenerBus(val sparkContext: SparkContext) extends Spa | |
| // Indicate if `stop()` is called | ||
| private val stopped = new AtomicBoolean(false) | ||
|
|
||
| /** A counter for dropped events. It will be reset every time we log it. */ | ||
| private val droppedEventsCounter = new AtomicLong(0L) | ||
|
|
||
| /** When `droppedEventsCounter` was logged last time. */ | ||
| @volatile private var lastReportTimestamp = 0L | ||
|
|
||
| // Indicate if we are processing some event | ||
| // Guarded by `self` | ||
| private var processingEvent = false | ||
|
|
@@ -123,6 +129,23 @@ private[spark] class LiveListenerBus(val sparkContext: SparkContext) extends Spa | |
| eventLock.release() | ||
| } else { | ||
| onDropEvent(event) | ||
| droppedEventsCounter.incrementAndGet() | ||
| } | ||
| // Don't log too frequently | ||
| if (System.currentTimeMillis() - lastReportTimestamp >= 60 * 1000) { | ||
| var droppedEvents = droppedEventsCounter.get | ||
| while (droppedEvents > 0) { | ||
|
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 do not quite get the purpose of this while loop. Should we just move forward if
Member
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 loop is not necessary. Updated. Also modified to check |
||
| // 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 we will try again. | ||
| if (droppedEventsCounter.compareAndSet(droppedEvents, 0)) { | ||
| lastReportTimestamp = System.currentTimeMillis() | ||
| logWarning(s"Dropped $droppedEvents SparkListenerEvents") | ||
|
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. Should we also log the lastReportTimestamp?
Member
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.
I don't think so since the log itself has the time info already. |
||
| return | ||
| } | ||
| droppedEvents = droppedEventsCounter.get | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
||
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.
Mention that it stores millis?