Duong created RATIS-2007:
----------------------------

             Summary: Zero-copy buffers are not released when clients 
disconnect (e.g. timeout)
                 Key: RATIS-2007
                 URL: https://issues.apache.org/jira/browse/RATIS-2007
             Project: Ratis
          Issue Type: Sub-task
            Reporter: Duong


Found this bug when working on adding assertions to ensure all zero-copy 
buffers are released in tests ().

When client connections are terminated, the `whenComplete` promise seems not 
executed. This leads to unreleased zero-copy buffers. For example, the 
whenComplete block as bellow may not be executed when clients time out. 
{code:java}
// In RaftServerImpl
@Override
public CompletableFuture<RaftClientReply> submitClientRequestAsync(
    ReferenceCountedObject<RaftClientRequest> requestRef) {
  final RaftClientRequest request = requestRef.retain();
  ...
  return replyFuture(requestRef).whenComplete((clientReply, exception) -> {
  requestRef.release();
  timerContext.ifPresent(Timekeeper.Context::stop);
  if (exception != null || clientReply.getException() != null) {
    raftServerMetrics.incFailedRequestCount(request.getType());
  }
}); {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to