In our Java application, when we are trying to kill Java Process programmatically using System.exit(0), the process is not getting killed for long time even after 5 minutes or 10 minutes.
When we took thread dump of that Java process, after 5 minutes we could see, Java process not getting killed as thread is waiting in Shutdown hook where we see await call with timeout period as 10 seconds but still the thread is not coming out of await method and its running indefinitely.
We had this issue always when we run with Amazon Corretto 11.0.17
later we upgraded to 11.0.24.8.1
To Reproduce
Have java application,
use Oracle UCP for connection pooling.
issue shutdown by calling System.exit(0)
This issue is random behavior.
Expected behavior
When we issue shutdown using System.exit(0) the process and its PID should be clean exit but not happening.
Screenshots
Two threads during the thread dump taken after 115 seconds (appx 2 min)
"Thread-2" #17 prio=5 os_prio=0 cpu=1.64ms elapsed=115.74s tid=0x00007f8836a4e800 nid=0x1be022 waiting on condition [0x00007f879110c000]
java.lang.Thread.State: TIMED_WAITING (parking)
at jdk.internal.misc.Unsafe.park(java.base@11.0.24/Native Method)
parking to wait for <0x0000000761b80270> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
at java.util.concurrent.locks.LockSupport.parkNanos(java.base@11.0.24/LockSupport.java:234)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(java.base@11.0.24/AbstractQueuedSynchronizer.java:2211)
at oracle.ucp.common.Core.waitForPendingGrowsToFinish(Core.java:2230)
at oracle.ucp.common.Core.access$2400(Core.java:79)
at oracle.ucp.common.Core$17.lambda$run$0(Core.java:2442)
at oracle.ucp.common.Core$17$$Lambda$795/0x0000000800b8f440.accept(Unknown Source)
at java.lang.Iterable.forEach(java.base@11.0.24/Iterable.java:75)
at java.util.Collections$SynchronizedCollection.forEach(java.base@11.0.24/Collections.java:2067)
locked <0x0000000762409c58> (a java.util.Collections$SynchronizedSet)
at oracle.ucp.common.Core$17.run(Core.java:2441)
"main" #1 prio=5 os_prio=0 cpu=20511.55ms elapsed=185707.18s tid=0x00007f883402c000 nid=0x15b49e in Object.wait() [0x00007f883e017000]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(java.base@11.0.24/Native Method)
waiting on
at java.lang.Thread.join(java.base@11.0.24/Thread.java:1300)
waiting to re-lock in wait() <0x0000000761f7c840> (a oracle.ucp.common.Core$17)
at java.lang.Thread.join(java.base@11.0.24/Thread.java:1375)
at java.lang.ApplicationShutdownHooks.runHooks(java.base@11.0.24/ApplicationShutdownHooks.java:107)
at java.lang.ApplicationShutdownHooks$1.run(java.base@11.0.24/ApplicationShutdownHooks.java:46)
at java.lang.Shutdown.runHooks(java.base@11.0.24/Shutdown.java:130)
at java.lang.Shutdown.exit(java.base@11.0.24/Shutdown.java:174)
locked <0x000000076140fd18> (a java.lang.Class for java.lang.Shutdown)
at java.lang.Runtime.exit(java.base@11.0.24/Runtime.java:116)
at java.lang.System.exit(java.base@11.0.24/System.java:1769)
at com.authentic.Executive.main(Executive.java:808)
Describe the bug
In our Java application, when we are trying to kill Java Process programmatically using System.exit(0), the process is not getting killed for long time even after 5 minutes or 10 minutes. When we took thread dump of that Java process, after 5 minutes we could see, Java process not getting killed as thread is waiting in Shutdown hook where we see await call with timeout period as 10 seconds but still the thread is not coming out of await method and its running indefinitely.
We had this issue always when we run with Amazon Corretto 11.0.17 later we upgraded to 11.0.24.8.1
To Reproduce
Have java application, use Oracle UCP for connection pooling. issue shutdown by calling System.exit(0)
This issue is random behavior.
Expected behavior
When we issue shutdown using System.exit(0) the process and its PID should be clean exit but not happening.
Screenshots
Two threads during the thread dump taken after 115 seconds (appx 2 min) "Thread-2" #17 prio=5 os_prio=0 cpu=1.64ms elapsed=115.74s tid=0x00007f8836a4e800 nid=0x1be022 waiting on condition [0x00007f879110c000] java.lang.Thread.State: TIMED_WAITING (parking) at jdk.internal.misc.Unsafe.park(java.base@11.0.24/Native Method)
"main" #1 prio=5 os_prio=0 cpu=20511.55ms elapsed=185707.18s tid=0x00007f883402c000 nid=0x15b49e in Object.wait() [0x00007f883e017000] java.lang.Thread.State: WAITING (on object monitor) at java.lang.Object.wait(java.base@11.0.24/Native Method)
Platform information