[
https://issues.apache.org/jira/browse/RATIS-2104?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17852877#comment-17852877
]
Duong commented on RATIS-2104:
------------------------------
{quote}The Java try-finally is very unlikely to has a bug. It will be a big
news if it is.
{quote}
I'm not saying it is a Java bug, but a designated behavior. This only happens
when the GRPC server is shutting down, meaning the executor threadpool is
shutting down, or the thread running the code with the try-finally block is
being killed/interrupted. Java [finally
document|https://docs.oracle.com/javase/tutorial/essential/exceptions/finally.html]
once had this note (look at the 2nd sentence, though it's been removed as per
[https://bugs.openjdk.org/browse/JDK-8276156]).
{quote}_Note: If the JVM exits while the try or catch code is being executed,
then the finally block may not execute. Likewise, if the thread executing the
try or catch code is interrupted or killed, the finally block may not execute
even though the application as a whole continues._
{quote}
I had a hard time trying to believe this :(, but it's very much reproducible,
you can try by adding [this
commit|https://github.com/duongkame/ratis/commit/ab742c687128ca2fe74036b7f554ea6791a91190]
and run the test until it fails. [~szetszwo]
> TestLeaderInstallSnapshot may fail with java.lang.IllegalStateException:
> allLeaks.size = 4
> ------------------------------------------------------------------------------------------
>
> Key: RATIS-2104
> URL: https://issues.apache.org/jira/browse/RATIS-2104
> Project: Ratis
> Issue Type: Bug
> Reporter: Tsz-wo Sze
> Priority: Major
> Time Spent: 40m
> Remaining Estimate: 0h
>
> I can reproduce it with ratis-3.1.0-rc0
> {code}
> [INFO] Running org.apache.ratis.grpc.TestLeaderInstallSnapshot
> [ERROR] Tests run: 2, Failures: 0, Errors: 2, Skipped: 0, Time elapsed:
> 65.892 s <<< FAILURE! - in org.apache.ratis.grpc.TestLeaderInstallSnapshot
> [ERROR]
> org.apache.ratis.grpc.TestLeaderInstallSnapshot.testInstallSnapshotLeaderSwitch(Boolean)[1]
> Time elapsed: 20.055 s <<< ERROR!
> java.lang.IllegalStateException: allLeaks.size = 4
> at org.apache.ratis.util.Preconditions.assertTrue(Preconditions.java:77)
> at
> org.apache.ratis.util.LeakDetector.assertNoLeaks(LeakDetector.java:107)
> at
> org.apache.ratis.server.impl.MiniRaftCluster.shutdown(MiniRaftCluster.java:869)
> at
> org.apache.ratis.grpc.MiniRaftClusterWithGrpc.shutdown(MiniRaftClusterWithGrpc.java:93)
> at
> org.apache.ratis.server.impl.MiniRaftCluster$Factory$Get.runWithNewCluster(MiniRaftCluster.java:149)
> at
> org.apache.ratis.server.impl.MiniRaftCluster$Factory$Get.runWithNewCluster(MiniRaftCluster.java:121)
> at
> org.apache.ratis.InstallSnapshotFromLeaderTests.testInstallSnapshotLeaderSwitch(InstallSnapshotFromLeaderTests.java:94)
> at
> org.apache.ratis.grpc.TestLeaderInstallSnapshot.testInstallSnapshotLeaderSwitch(TestLeaderInstallSnapshot.java:53)
> {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)