RATIS-2303. Migrate ratis-examples tests to Junit 5.#1267
RATIS-2303. Migrate ratis-examples tests to Junit 5.#1267szetszwo merged 1 commit intoapache:masterfrom
Conversation
|
@szetszwo @adoroszlai While upgrading the ratis-examples module, I discovered an issue where the workerGroup might not be properly shut down, causing unit tests to fail with the following exception. I will walk through the entire process of analyzing the issue, in hopes that it can offer some troubleshooting guidance to others facing similar problems.
This logic increments the reference count at line 97 with I added trace logs to the From the logs, I found that 30 object references were created, but only 15 were released. This indicates that some logic is not properly releasing the There are two main call chains involved:
By examining the code, we can see that
With the modification, the unit tests now run and pass successfully. |
| @Override | ||
| public CompletableFuture<DataStream> stream(RaftClientRequest request) { | ||
| final SingleDataStream s = new SingleDataStream(request); | ||
| LOG.info("XXX {} put {}, {}", this, ClientInvocationId.valueOf(request), s); |
There was a problem hiding this comment.
I optimized the logs by removing the XXX prefix. I understand it was likely added for debugging purposes, but such prefixes are not appropriate in a production environment.
|
@szetszwo @adoroszlai RATIS-2303 has passed all checks. Although some unit tests are failing, the fixes are relatively straightforward. I'm considering including them directly in this PR. Could you please review this pr? Thank you very much! |
szetszwo
left a comment
There was a problem hiding this comment.
+1 the change looks good.
| } | ||
| for (Future<FileStoreWriter> future : writerFutures) { | ||
| future.get(); | ||
| future.get().close(); |
There was a problem hiding this comment.
This is a good catch! A new client is created for each write, we should close them.
There was a problem hiding this comment.
@szetszwo Thank you very much for reviewing the code!
(cherry picked from commit 5528be0)



What changes were proposed in this pull request?
Migrate ratis-examples tests to Junit 5.
What is the link to the Apache JIRA
JIRA: RATIS-2303. Migrate ratis-examples tests to Junit 5.
How was this patch tested?
mvn clean test.