Skip to content

Commit b4f56a0

Browse files
committed
Address
1 parent f580ce1 commit b4f56a0

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

core/src/main/scala/org/apache/spark/scheduler/LiveListenerBus.scala

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -131,20 +131,19 @@ private[spark] class LiveListenerBus(val sparkContext: SparkContext) extends Spa
131131
onDropEvent(event)
132132
droppedEventsCounter.incrementAndGet()
133133
}
134-
// Don't log too frequently
135-
if (System.currentTimeMillis() - lastReportTimestamp >= 60 * 1000) {
136-
var droppedEvents = droppedEventsCounter.get
137-
while (droppedEvents > 0) {
134+
135+
val droppedEvents = droppedEventsCounter.get
136+
if (droppedEvents > 0) {
137+
// Don't log too frequently
138+
if (System.currentTimeMillis() - lastReportTimestamp >= 60 * 1000) {
138139
// There may be multiple threads trying to decrease droppedEventsCounter.
139140
// Use "compareAndSet" to make sure only one thread can win.
140-
// And if another thread is increasing droppedEventsCounter, "compareAndSet" will fail
141-
// and we will try again.
141+
// And if another thread is increasing droppedEventsCounter, "compareAndSet" will fail and
142+
// then that thread will update it.
142143
if (droppedEventsCounter.compareAndSet(droppedEvents, 0)) {
143144
lastReportTimestamp = System.currentTimeMillis()
144145
logWarning(s"Dropped $droppedEvents SparkListenerEvents")
145-
return
146146
}
147-
droppedEvents = droppedEventsCounter.get
148147
}
149148
}
150149
}

0 commit comments

Comments
 (0)