GitHub user andrewor14 opened a pull request:

    https://github.com/apache/spark/pull/544

    [SPARK-1615] Synchronize accesses to the LiveListenerBus' event queue

    Much of SparkListenerSuite relies on LiveListenerBus's `waitUntilEmpty()` 
method. As the name suggests, this waits until the event queue is empty. 
However, the following race condition could happen:
    
    (1) We dequeue an event
    (2) The queue is empty, we return true (even though the event has not been 
processed)
    (3) The test asserts something assuming that all listeners have finished 
executing (and fails)
    (4) The listeners receive and process the event
    
    This has been a possible race condition for a long time, but for some 
reason we've never run into it.
    
    This PR makes (1) and (4) atomic by synchronizing around it. To do that, 
however, we must avoid using `eventQueue.take`, which is blocking and will 
cause a deadlock if we synchronize around it. As a workaround, we use the 
non-blocking `eventQueue.poll` + a semaphore to provide the same semantics.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/andrewor14/spark stage-info-test-fix

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/spark/pull/544.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #544
    
----
commit eb486ae4c1d95682c0ebeb62edb242109210312e
Author: Andrew Or <[email protected]>
Date:   2014-04-25T00:21:51Z

    Synchronize accesses to the LiveListenerBus' event queue
    
    This guards against the race condition in which we (1) dequeue an event,
    and (2) check for queue emptiness before (3) actually processing the
    event in all attached listeners.
    
    The solution is to make steps (1) and (3) atomic relatively to (2).

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to