[ 
https://issues.apache.org/jira/browse/ARROW-7343?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16991621#comment-16991621
 ] 

David Li commented on ARROW-7343:
---------------------------------

I think a reasonable fix is to have a flag on ArrowMessage indicating whether 
we've transitioned ownership of the buffer to Netty/gRPC; if we send a message 
and the flag isn't set, then we should immediately clean up the buffers. (I'm 
wondering if there is a case where we transition ownership to Netty but Netty 
itself drops the buffers, I don't believe there is such a case.)

There are some follow up issues I want to investigate and maybe file:
 * Is DoPut susceptible to the same issue? (Probably.)
 * {{ServerStreamListener#isCancelled}} is rather useless, since gRPC actually 
maintains two distinct (and only somewhat correlated) flags for whether a call 
has been cancelled, and only the one one that isn't easily observable by 
application code actually matters. (Maybe this is worth filing an upstream bug, 
and maybe we can wrap gRPC to expose stronger semantics - but I'm not sure 
given the asynchronicity of gRPC.)
 * In general, we should review how we're wrapping gRPC concepts and either 
make precise the guarantees we provide relative to gRPC, or make sure we 
actually expose the full range of gRPC concepts.
 * Again, maybe we really need an async API, at least in Java; while the sync 
API is more convenient, it does lead to weird issues like this.

> [Java] Memory leak in Flight DoGet when client cancels
> ------------------------------------------------------
>
>                 Key: ARROW-7343
>                 URL: https://issues.apache.org/jira/browse/ARROW-7343
>             Project: Apache Arrow
>          Issue Type: Bug
>          Components: FlightRPC, Java
>    Affects Versions: 0.14.0
>            Reporter: David Li
>            Assignee: David Li
>            Priority: Major
>
> I believe this causes things like ARROW-4765.
> -If a stream is interrupted or otherwise not drained by the client, the 
> serialized form of the ArrowMessage (DrainableByteBufInputStream) will sit 
> around forever, leaking memory.-



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to