Github user JoshRosen commented on a diff in the pull request:

    https://github.com/apache/spark/pull/11193#discussion_r52834480
  
    --- Diff: 
network/common/src/main/java/org/apache/spark/network/protocol/MessageEncoder.java
 ---
    @@ -49,11 +49,15 @@ public void encode(ChannelHandlerContext ctx, Message 
in, List<Object> out) thro
     
         // If the message has a body, take it out to enable zero-copy transfer 
for the payload.
         if (in.body() != null) {
    +      bodyLength = in.body().size();
    +      if (bodyLength > 0) {
    +        in.body().retain();
    --- End diff --
    
    I realized that this is slightly wrong: we assume that `in.body()` has a 
ref count of at least one when it's passed in and ownership of that reference 
is transferred to this method.
    
    Therefore, we should not add an extra retain here. In order to fix tests, 
though, I need to add a missing retain to ensure that the message passed in 
here has a non-zero ref. count for its inner Netty buffer.


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