-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-24309][CORE] AsyncEventQueue should stop on interrupt. #21356
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 all commits
a689f52
0a44c06
4a1f657
09d55af
fc8a197
008d14d
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 |
|---|---|---|
|
|
@@ -60,6 +60,15 @@ private[spark] trait ListenerBus[L <: AnyRef, E] extends Logging { | |
| } | ||
| } | ||
|
|
||
| /** | ||
| * This can be overriden by subclasses if there is any extra cleanup to do when removing a | ||
| * listener. In particular AsyncEventQueues can clean up queues in the LiveListenerBus. | ||
| */ | ||
| def removeListenerOnError(listener: L): Unit = { | ||
| removeListener(listener) | ||
| } | ||
|
|
||
|
|
||
| /** | ||
| * Post the event to all registered listeners. The `postToAll` caller should guarantee calling | ||
| * `postToAll` in the same thread for all events. | ||
|
|
@@ -80,7 +89,16 @@ private[spark] trait ListenerBus[L <: AnyRef, E] extends Logging { | |
| } | ||
| try { | ||
| doPostEvent(listener, event) | ||
| if (Thread.interrupted()) { | ||
|
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. This is ok right now since Spark code never explicitly interrupts these threads. If we ever need to do that, though, this might become a problem... but in that case I don't know how you'd handle this issue without just giving up and stopping everything. But... is this correct? Your test just calls
Contributor
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. yeah agree, I will handle this too -- but I'll wait to update till there is agreement on the right overall approach
Contributor
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.
If spark were to explicitly interrupt, then I think we'd also set some other flag indicating a reason, eg. I've pushed an update to handle |
||
| // We want to throw the InterruptedException right away so we can associate the interrupt | ||
| // with this listener, as opposed to waiting for a queue.take() etc. to detect it. | ||
| throw new InterruptedException() | ||
| } | ||
| } catch { | ||
| case ie: InterruptedException => | ||
| logError(s"Interrupted while posting to ${Utils.getFormattedClassName(listener)}. " + | ||
| s"Removing that listener.", ie) | ||
| removeListenerOnError(listener) | ||
| case NonFatal(e) if !isIgnorableException(e) => | ||
| logError(s"Listener ${Utils.getFormattedClassName(listener)} threw an exception", e) | ||
| } finally { | ||
|
|
||
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.
it's ok to leave this, but this doesn't happen anymore, right?
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.
It does still happen, we need this. We see the interrupt in postToAll, which is in the queue thread. If it fails, we call
removeListenerOnError. If that results in the queue being empty, we stop the queue.