GitHub user vanzin opened a pull request:

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

     [SPARK-6578] [core] Fix thread-safety issue in outbound path of network 
library.

    While the inbound path of a netty pipeline is thread-safe, the outbound
    path is not. That means that multiple threads can compete to write messages
    to the next stage of the pipeline.
    
    The network library sometimes breaks a single RPC message into multiple
    buffers internally to avoid copying data (see MessageEncoder). This can
    result in the following scenario (where "FxBy" means "frame x, buffer y"):
    
                   T1         F1B1            F1B2
                                \               \
                                 \               \
                   socket        F1B1   F2B1    F1B2  F2B2
                                         /             /
                                        /             /
                   T2                  F2B1         F2B2
    
    And the frames now cannot be rebuilt on the receiving side because the
    different messages have been mixed up on the wire.
    
    The fix wraps these multi-buffer messages into a `FileRegion` object
    so that these messages are written "atomically" to the next pipeline 
handler.

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

    $ git pull https://github.com/vanzin/spark SPARK-6578-1.2

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

    https://github.com/apache/spark/pull/5336.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 #5336
    
----
commit 526f230b4a3a6dfc53139c6a31d0499af60b8ac2
Author: Marcelo Vanzin <[email protected]>
Date:   2015-04-01T23:06:11Z

    [SPARK-6578] [core] Fix thread-safety issue in outbound path of network 
library.
    
    While the inbound path of a netty pipeline is thread-safe, the outbound
    path is not. That means that multiple threads can compete to write messages
    to the next stage of the pipeline.
    
    The network library sometimes breaks a single RPC message into multiple
    buffers internally to avoid copying data (see MessageEncoder). This can
    result in the following scenario (where "FxBy" means "frame x, buffer y"):
    
                   T1         F1B1            F1B2
                                \               \
                                 \               \
                   socket        F1B1   F2B1    F1B2  F2B2
                                         /             /
                                        /             /
                   T2                  F2B1         F2B2
    
    And the frames now cannot be rebuilt on the receiving side because the
    different messages have been mixed up on the wire.
    
    The fix wraps these multi-buffer messages into a `FileRegion` object
    so that these messages are written "atomically" to the next pipeline 
handler.
    
    Author: Marcelo Vanzin <[email protected]>
    
    Closes #5234 from vanzin/SPARK-6578 and squashes the following commits:
    
    16b2d70 [Marcelo Vanzin] Forgot to update a type.
    c9c2e4e [Marcelo Vanzin] Review comments: simplify some code.
    9c888ac [Marcelo Vanzin] Small style nits.
    8474bab [Marcelo Vanzin] Fix multiple calls to 
MessageWithHeader.transferTo().
    e26509f [Marcelo Vanzin] Merge branch 'master' into SPARK-6578
    c503f6c [Marcelo Vanzin] Implement a custom FileRegion instead of using 
locks.
    84aa7ce [Marcelo Vanzin] Rename handler to the correct name.
    432f3bd [Marcelo Vanzin] Remove unneeded method.
    8d70e60 [Marcelo Vanzin] Fix thread-safety issue in outbound path of 
network library.
    
    (cherry picked from commit f084c5de14eb10a6aba82a39e03e7877926ebb9e)
    
    Conflicts:
        network/common/pom.xml

commit 4d3395ec8e1882abbc56860dc9b5083c7bbd2bec
Author: Reynold Xin <[email protected]>
Date:   2015-04-02T01:36:06Z

    [SPARK-6578] Small rewrite to make the logic more clear in 
MessageWithHeader.transferTo.
    
    Author: Reynold Xin <[email protected]>
    
    Closes #5319 from rxin/SPARK-6578 and squashes the following commits:
    
    7c62a64 [Reynold Xin] Small rewrite to make the logic more clear in 
transferTo.
    
    (cherry picked from commit 899ebcb1448126f40be784ce42e69218e9a1ead7)

----


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