[
https://issues.apache.org/jira/browse/RATIS-2007?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17811565#comment-17811565
]
Tsz-wo Sze commented on RATIS-2007:
-----------------------------------
[~duongnguyen], let's file a new JIRA for the other leaks unless we want to
revert the commit. We usually reopen a merged JIRA for reverting it.
> Zero-copy buffers are not released
> ----------------------------------
>
> Key: RATIS-2007
> URL: https://issues.apache.org/jira/browse/RATIS-2007
> Project: Ratis
> Issue Type: Sub-task
> Components: server
> Reporter: Duong
> Assignee: Duong
> Priority: Major
> Fix For: 3.1.0
>
> Time Spent: 50m
> Remaining Estimate: 0h
>
> 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)