GitHub user BryanCutler opened a pull request:

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

    [SPARK-12717][PYTHON] Adding thread-safe broadcast pickle registry

    ## What changes were proposed in this pull request?
    
    When using PySpark broadcast variables in a multi-threaded environment,  
`SparkContext._pickled_broadcast_vars` becomes a shared resource.  A race 
condition can occur when broadcast variables that are pickled from one thread 
get added to the shared ` _pickled_broadcast_vars` and become part of the 
python command from another thread.  This PR introduces a thread-safe pickled 
registry using thread local storage so that when python command is pickled 
(causing the broadcast variable to be pickled and added to the registry) each 
thread will have their own view of the pickle registry to retrieve and clear 
the broadcast variables used.
    
    ## How was this patch tested?
    
    Added a unit test that causes this race condition using another thread.


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

    $ git pull https://github.com/BryanCutler/spark branch-2.2

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

    https://github.com/apache/spark/pull/18823.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 #18823
    
----
commit 67b14db47b79e320ab93440de558b1716f3a4152
Author: Bryan Cutler <[email protected]>
Date:   2017-07-20T21:36:09Z

    Added thread-safe broadcast pickle registry, using thread local storage
    
    added regression test for multithreaded broadcast pickle

----


---
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.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to