ankurdave commented on a change in pull request #34245:
URL: https://github.com/apache/spark/pull/34245#discussion_r727612187
##########
File path: core/src/main/scala/org/apache/spark/TaskContextImpl.scala
##########
@@ -82,23 +82,33 @@ private[spark] class TaskContextImpl(
@volatile private var _fetchFailedException: Option[FetchFailedException] =
None
@GuardedBy("this")
- override def addTaskCompletionListener(listener: TaskCompletionListener)
- : this.type = synchronized {
- if (completed) {
+ override def addTaskCompletionListener(listener: TaskCompletionListener):
this.type = {
+ val needToCallListener = synchronized {
+ if (completed) {
+ true
+ } else {
+ onCompleteCallbacks += listener
+ false
+ }
+ }
Review comment:
Hmm, good point that we'd be changing the behavior of this API. It would
be nice to preserve the sequential execution behavior, but it does seem pretty
complex. I can try implementing it and see whether it's worth it.
Either way, we should probably document and test the behavior more
thoroughly. In the current state of the PR, I think the guarantee is something
like the following: "Two listeners registered in the same thread will be
invoked in reverse order of registration if the task finishes after both are
registered. There are no ordering guarantees for listeners registered in
different threads, and they may execute concurrently."
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]