connection object from hikaricp connection pool

user3813256

I am using hikaricp (this would probably apply to any other Database connection pool as well). I have a DBPool class in which I instantiate a HikariDataSource (using the HikariConfig object). I am using the lazy holder idiom for this DBPool to limit one pool instance per VM. However, once you get a reference to the pool, you can retrieve the Connection object (without any further locks/synchronization/semaphore checks) since I thought the connection pool would take care of my connection object limits. Evertime I get the connection reference via the DBPool, I call close on the connection/preparedstatement/resultset. I could try a try with resources if that's causing an issue. I am observing the following in the logs:

2014-09-14 18:53:25,302 WARN c.z.h.p.LeakTask [Hikari Housekeeping Timer (pool testHikariCp)] Connection leak detection triggered, stack trace follows java.lang.Exception
        at com.akkadian.db.DBConnPool.getConnection(DBConnPool.java:67)
        at models.tester.storeload.testAlertLogStoreLoad.loadAll(testAlertChk.java:101)
        at com.testLib.map.MapStoreWrapper.loadAll(MapStoreWrapper.java:131)
        at com.testLib.map.mapstore.AbstractMapDataStore.loadAll(AbstractMapDataStore.java:40)
        at com.testLib.map.BasicRecordStoreLoader$MapLoadAllTask.run(BasicRecordStoreLoader.java:340)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at com.testLib.util.executor.CompletableFutureTask.run(CompletableFutureTask.java:57)
        at com.testLib.util.executor.CachedExecutorServiceDelegate$Worker.run(CachedExecutorServiceDelegate.java:209)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
        at com.testLib.util.executor.testLibManagedThread.executeRun(testLibManagedThread.java:76)
        at com.testLib.util.executor.testLibManagedThread.run(testLibManagedThread.java:92)

I increased the connection timeout and set the leakDetectionthreshold as follows:

     hikariConfig.setConnectionTimeout(90000); 
     hikariConfig.setLeakDetectionThreshold(10000); 

I also increased the size of the pool even though it was recommended not to - I had to test various options since I was receiving connection timeouts from the database.

ali haider

Make sure that you are indeed releasing the connection back to the pool? Can you use try with resources (in addition to increasing threshold as Brett mentioned):

try (Connection conn = DBConnectionPool.getConnection(); 
        PreparedStatement ps = conn.prepareStatement(preparedQuery);) {

and the resultset (because some drivers/databases may not clean out resultset when connection is cleaned though not sure if this is still valid for new drivers/databases but I'm not sure what you are using):

try (ResultSet rs = ps.executeQuery();) {

Increase the leak detection threshold if needed though I think if you have to make it too large, you have an issue which needs to be fixed.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

connection object from hikaricp connection pool

From Dev

HikariCP - Setting connected database dynamically on connection check-in and check-out from connection pool

From Dev

Best approach for returning connection objects to HikariCP pool

From Dev

HikariCP Connection Pool immediately creates 100 connections

From Dev

Integrate Spring Boot with EBean and HikariCP Connection Pool

From Dev

Using HikariCP's connection pool the correct way

From Dev

Integrate Spring Boot with EBean and HikariCP Connection Pool

From Dev

Returning db connection to HikariCP pool with Slick 3.1.x

From Dev

How do I properly close a HikariCP Connection Pool

From Dev

Hikaricp Oracle connection issue

From Java

HikariCP - connection is not available

From Dev

HikariCP connection error

From Dev

HikariCP connection leak detection and hibernate

From Dev

HikariCP connection leak detection and hibernate

From Dev

Why and when should an idle database connection be retired from a connection pool?

From Dev

Why and when should an idle database connection be retired from a connection pool?

From Dev

Retrieve a native connection from hikari-cp connection pool

From Dev

Unable to Connect to JDBC Connection Pool from Glassfish

From Dev

Unable to Connect to JDBC Connection Pool from Glassfish

From Dev

Static class to get connections from connection pool

From Dev

StormCrawler: Timeout waiting for connection from pool

From Dev

Apache AsyncHttpClient 4.1.4 creating new socket connection instead of reusing connection from Connection pool

From Dev

Goroutines blocked connection pool

From Dev

Inject database connection pool

From Dev

Tomcat Connection Pool Monitoring

From Dev

SQLAlchemy Connection Pool and Sessions

From Dev

Tomcat connection pool with MyBatis

From Dev

Hbase 1.0.0 connection pool

From Dev

database connection pool purpose?

Related Related

  1. 1

    connection object from hikaricp connection pool

  2. 2

    HikariCP - Setting connected database dynamically on connection check-in and check-out from connection pool

  3. 3

    Best approach for returning connection objects to HikariCP pool

  4. 4

    HikariCP Connection Pool immediately creates 100 connections

  5. 5

    Integrate Spring Boot with EBean and HikariCP Connection Pool

  6. 6

    Using HikariCP's connection pool the correct way

  7. 7

    Integrate Spring Boot with EBean and HikariCP Connection Pool

  8. 8

    Returning db connection to HikariCP pool with Slick 3.1.x

  9. 9

    How do I properly close a HikariCP Connection Pool

  10. 10

    Hikaricp Oracle connection issue

  11. 11

    HikariCP - connection is not available

  12. 12

    HikariCP connection error

  13. 13

    HikariCP connection leak detection and hibernate

  14. 14

    HikariCP connection leak detection and hibernate

  15. 15

    Why and when should an idle database connection be retired from a connection pool?

  16. 16

    Why and when should an idle database connection be retired from a connection pool?

  17. 17

    Retrieve a native connection from hikari-cp connection pool

  18. 18

    Unable to Connect to JDBC Connection Pool from Glassfish

  19. 19

    Unable to Connect to JDBC Connection Pool from Glassfish

  20. 20

    Static class to get connections from connection pool

  21. 21

    StormCrawler: Timeout waiting for connection from pool

  22. 22

    Apache AsyncHttpClient 4.1.4 creating new socket connection instead of reusing connection from Connection pool

  23. 23

    Goroutines blocked connection pool

  24. 24

    Inject database connection pool

  25. 25

    Tomcat Connection Pool Monitoring

  26. 26

    SQLAlchemy Connection Pool and Sessions

  27. 27

    Tomcat connection pool with MyBatis

  28. 28

    Hbase 1.0.0 connection pool

  29. 29

    database connection pool purpose?

HotTag

Archive