[ 
https://issues.apache.org/jira/browse/RATIS-2007?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Duong updated RATIS-2007:
-------------------------
    Description: 
Found this bug when working on adding assertions to ensure all zero-copy 
buffers are released in tests (RATIS-1978).

When client connections are terminated, the `whenComplete` promise seems not 
executed. This leads to unreleased zero-copy buffers. For example, the 
whenComplete block as below 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}

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

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}


> 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
>            Priority: Major
>
> Found this bug when working on adding assertions to ensure all zero-copy 
> buffers are released in tests (RATIS-1978).
> When client connections are terminated, the `whenComplete` promise seems not 
> executed. This leads to unreleased zero-copy buffers. For example, the 
> whenComplete block as below 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