duongkame commented on PR #1007:
URL: https://github.com/apache/ratis/pull/1007#issuecomment-1888386731

   > @duongkame , the grpc tests keep failing. This failure seems related to 
buffer corruption 
https://github.com/apache/ratis/actions/runs/7493450746/job/20404797679?pr=1007#step:6:656
   
   Turns out, it's specific to MessageStream API. 
`MessageStreamRequests.PendingStream` keeps a raw reference to the message 
buffer of all the pending request.
   
   In `MessageStreamRequests.PendingStream.append`:
   ```
   synchronized CompletableFuture<ByteString> append(long messageId, Message 
message) {
         ...
         bytes = bytes.concat(message.getContent());
         return CompletableFuture.completedFuture(bytes);
       }
   ```
   The `bytes.concat(message.getContent())` only creates a wrapper of the two 
`ByteStrings` (RopeByteString). And this makes the resulting `bytes` keep 
references to all of the pending message request buffers without reference 
counting.
   
   We can either just copy the message. 
   ```bytes = bytes.concat(copy(message.getContent()));```
   or make PendingStream keeping all the counters to all the previous requests 
in the stream.
   
   Think for this case we should just copy. @szetszwo 
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to