Skip to content

RATIS-2426. Fix memory leak in ServerRequestStreamObserver#1368

Open
ivandika3 wants to merge 14 commits intoapache:masterfrom
ivandika3:RATIS-2426
Open

RATIS-2426. Fix memory leak in ServerRequestStreamObserver#1368
ivandika3 wants to merge 14 commits intoapache:masterfrom
ivandika3:RATIS-2426

Conversation

@ivandika3
Copy link
Copy Markdown
Contributor

@ivandika3 ivandika3 commented Mar 9, 2026

What changes were proposed in this pull request?

Please refer to https://issues.apache.org/jira/browse/RATIS-2426

What is the link to the Apache JIRA

https://issues.apache.org/jira/browse/RATIS-2426

How was this patch tested?

UT

@ivandika3 ivandika3 changed the title Ratis 2426 RATIS-2426. Fix memory leak in ServerRequestStreamObserver Mar 9, 2026
@ivandika3 ivandika3 marked this pull request as ready for review March 12, 2026 04:09
Copy link
Copy Markdown
Contributor

@szetszwo szetszwo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ivandika3 , thanks for working on this! Please see the comment inlined. (Sorry that I missed this PR earlier.)

if (event == Event.COMPLETE) {
onCompleted();
} else {
cancelStream("stop due to " + event);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have the following call sequence:

  • AppendLogResponseHandler.onError(..) / onCompleted() -> resetClient(..) -> stop()

In the gRPC example,

  • onCompleted() implementation will response onCompleted() but
  • onError(Throwable t) only calls logger.log(Level.WARNING, ...)

So, I think stop() should not call cancelStream(..)

*/
@ParameterizedTest
@MethodSource("data")
public void testLogAppenderStreamCleanupOnRestart(Boolean separateHeartbeat) throws Exception {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to revert GrpcLogAppender and GrpcServerProtocolService (except for GRPC_SERVER_HANDLE_ERROR). Both testLogAppenderStreamCleanupOnRestart and testFollowerHandleErrorCleanup can pass. So, they probably cannot test the code change.

@ivandika3
Copy link
Copy Markdown
Contributor Author

@szetszwo Thanks for the review. I'm still not 100% sure about this fix yet. I'll revisit this when I have time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants