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.
// 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()); } });
Attachments
Issue Links
- is related to
-
RATIS-2018 Zero-copy buffers are not released - 2nd chunk
- Resolved
- links to