During the refactoring process of https://github.com/JNOSQL/demos-se ArangoDB module to use the JNoSQL Databases implementation, I needed to perform the **App*** sample classes in order to make sure that the after the changes the code still working properly, but I detected that the executions didn't end up after performing the main method block.
In order to figure out the reason why for this behavior, I've used jstack to get a thread dump. I've been able to detect that the ArangoDB connection pool wasn't shut down when the ArangoDBDocumentManager implementation was destroyed during the CDI context shutdown. Here is the dump file: jstack.txt
JNoSQL Version
1.0.0-SNAPSHOT
Steps To Reproduce
By Intellij IDE, you just need to execute any of the org.jnosql.demo.se.App* classes to reproduce this behavior;
Expected Results
When any connection pool is no more necessary then it's recommended to close them in order to avoid connection leaks problems;
In the demos-se project scenario, the code is using CDI then it's expected that any database connection pool must be closed automatically during the CDI shutdown process.
Here is the full dump file: jstack.txt
In order to facilitate the visualization, the evidences are below:
"pool-1-thread-1" #44 prio=5 os_prio=0 cpu=0.95ms elapsed=27.06s tid=0x00007f14c8a784d0 nid=0x7de5 runnable [0x00007f14a82e5000]
java.lang.Thread.State: RUNNABLE
at sun.nio.ch.SocketDispatcher.read0(java.base@17/Native Method)
at sun.nio.ch.SocketDispatcher.read(java.base@17/SocketDispatcher.java:47)
at sun.nio.ch.NioSocketImpl.tryRead(java.base@17/NioSocketImpl.java:261)
at sun.nio.ch.NioSocketImpl.implRead(java.base@17/NioSocketImpl.java:312)
at sun.nio.ch.NioSocketImpl.read(java.base@17/NioSocketImpl.java:350)
at sun.nio.ch.NioSocketImpl$1.read(java.base@17/NioSocketImpl.java:803)
at java.net.Socket$SocketInputStream.read(java.base@17/Socket.java:966)
at com.arangodb.internal.velocystream.internal.VstConnection.readBytesIntoBuffer(VstConnection.java:346)
at com.arangodb.internal.velocystream.internal.VstConnection.readBytes(VstConnection.java:340)
at com.arangodb.internal.velocystream.internal.VstConnection.readChunk(VstConnection.java:315)
at com.arangodb.internal.velocystream.internal.VstConnection.lambda$open$0(VstConnection.java:212)
at com.arangodb.internal.velocystream.internal.VstConnection$$Lambda$345/0x0000000800e5bba8.call(Unknown Source)
at java.util.concurrent.FutureTask.run$$$capture(java.base@17/FutureTask.java:264)
at java.util.concurrent.FutureTask.run(java.base@17/FutureTask.java)
at java.util.concurrent.ThreadPoolExecutor.runWorker(java.base@17/ThreadPoolExecutor.java:1136)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(java.base@17/ThreadPoolExecutor.java:635)
at java.lang.Thread.run(java.base@17/Thread.java:833)
Locked ownable synchronizers:
- <0x0000000719227a80> (a java.util.concurrent.locks.ReentrantLock$NonfairSync)
- <0x000000071926cc18> (a java.util.concurrent.ThreadPoolExecutor$Worker)
"pool-2-thread-1" #45 prio=5 os_prio=0 cpu=0.42ms elapsed=27.03s tid=0x00007f14c8a8aea0 nid=0x7de6 runnable [0x00007f14993fa000]
java.lang.Thread.State: RUNNABLE
at sun.nio.ch.SocketDispatcher.read0(java.base@17/Native Method)
at sun.nio.ch.SocketDispatcher.read(java.base@17/SocketDispatcher.java:47)
at sun.nio.ch.NioSocketImpl.tryRead(java.base@17/NioSocketImpl.java:261)
at sun.nio.ch.NioSocketImpl.implRead(java.base@17/NioSocketImpl.java:312)
at sun.nio.ch.NioSocketImpl.read(java.base@17/NioSocketImpl.java:350)
at sun.nio.ch.NioSocketImpl$1.read(java.base@17/NioSocketImpl.java:803)
at java.net.Socket$SocketInputStream.read(java.base@17/Socket.java:966)
at com.arangodb.internal.velocystream.internal.VstConnection.readBytesIntoBuffer(VstConnection.java:346)
at com.arangodb.internal.velocystream.internal.VstConnection.readBytes(VstConnection.java:340)
at com.arangodb.internal.velocystream.internal.VstConnection.readChunk(VstConnection.java:315)
at com.arangodb.internal.velocystream.internal.VstConnection.lambda$open$0(VstConnection.java:212)
at com.arangodb.internal.velocystream.internal.VstConnection$$Lambda$345/0x0000000800e5bba8.call(Unknown Source)
at java.util.concurrent.FutureTask.run$$$capture(java.base@17/FutureTask.java:264)
at java.util.concurrent.FutureTask.run(java.base@17/FutureTask.java)
at java.util.concurrent.ThreadPoolExecutor.runWorker(java.base@17/ThreadPoolExecutor.java:1136)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(java.base@17/ThreadPoolExecutor.java:635)
at java.lang.Thread.run(java.base@17/Thread.java:833)
Locked ownable synchronizers:
- <0x0000000719073ae0> (a java.util.concurrent.locks.ReentrantLock$NonfairSync)
- <0x0000000719076930> (a java.util.concurrent.ThreadPoolExecutor$Worker)
"pool-3-thread-1" #46 prio=5 os_prio=0 cpu=0.39ms elapsed=27.02s tid=0x00007f14c8a91f30 nid=0x7de7 runnable [0x00007f1498cf3000]
java.lang.Thread.State: RUNNABLE
at sun.nio.ch.SocketDispatcher.read0(java.base@17/Native Method)
at sun.nio.ch.SocketDispatcher.read(java.base@17/SocketDispatcher.java:47)
at sun.nio.ch.NioSocketImpl.tryRead(java.base@17/NioSocketImpl.java:261)
at sun.nio.ch.NioSocketImpl.implRead(java.base@17/NioSocketImpl.java:312)
at sun.nio.ch.NioSocketImpl.read(java.base@17/NioSocketImpl.java:350)
at sun.nio.ch.NioSocketImpl$1.read(java.base@17/NioSocketImpl.java:803)
at java.net.Socket$SocketInputStream.read(java.base@17/Socket.java:966)
at com.arangodb.internal.velocystream.internal.VstConnection.readBytesIntoBuffer(VstConnection.java:346)
at com.arangodb.internal.velocystream.internal.VstConnection.readBytes(VstConnection.java:340)
at com.arangodb.internal.velocystream.internal.VstConnection.readChunk(VstConnection.java:315)
at com.arangodb.internal.velocystream.internal.VstConnection.lambda$open$0(VstConnection.java:212)
at com.arangodb.internal.velocystream.internal.VstConnection$$Lambda$345/0x0000000800e5bba8.call(Unknown Source)
at java.util.concurrent.FutureTask.run$$$capture(java.base@17/FutureTask.java:264)
at java.util.concurrent.FutureTask.run(java.base@17/FutureTask.java)
at java.util.concurrent.ThreadPoolExecutor.runWorker(java.base@17/ThreadPoolExecutor.java:1136)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(java.base@17/ThreadPoolExecutor.java:635)
at java.lang.Thread.run(java.base@17/Thread.java:833)
Locked ownable synchronizers:
- <0x00000007191572a8> (a java.util.concurrent.locks.ReentrantLock$NonfairSync)
- <0x000000071915a0f8> (a java.util.concurrent.ThreadPoolExecutor$Worker)
Which JNoSQL project the issue refers to?
JNoSQL Databases
Bug description
During the refactoring process of https://github.com/JNOSQL/demos-se ArangoDB module to use the JNoSQL Databases implementation, I needed to perform the **App*** sample classes in order to make sure that the after the changes the code still working properly, but I detected that the executions didn't end up after performing the main method block.
In order to figure out the reason why for this behavior, I've used
jstack
to get a thread dump. I've been able to detect that the ArangoDB connection pool wasn't shut down when the ArangoDBDocumentManager implementation was destroyed during the CDI context shutdown. Here is the dump file: jstack.txtJNoSQL Version
1.0.0-SNAPSHOT
Steps To Reproduce
By Intellij IDE, you just need to execute any of the
org.jnosql.demo.se.App
* classes to reproduce this behavior;Expected Results
When any connection pool is no more necessary then it's recommended to close them in order to avoid connection leaks problems;
In the
demos-se
project scenario, the code is using CDI then it's expected that any database connection pool must be closed automatically during the CDI shutdown process.Code example, screenshot, or link to a repository
Here's the module: https://github.com/JNOSQL/demos-se/tree/main/arangodb
Here is the full dump file: jstack.txt In order to facilitate the visualization, the evidences are below: