brettwooldridge / HikariCP

光 HikariCP・A solid, high-performance, JDBC connection pool at last.
Apache License 2.0
19.71k stars 2.91k forks source link

Inactive sessions more than minimumIdle #1423

Open chakrim99 opened 4 years ago

chakrim99 commented 4 years ago

HikariCP version: 2.7.9 and 3.3.1 JDK version : 1.8.0_92-b14 Database : Oracle Database 12c Standard Edition Release 12.1.0.2.0 - 64bit Production Driver version : 4.0

Configuration used: <Resource auth="Container" connectionInitSql="select 1 from dual" driverClassName="oracle.jdbc.OracleDriver" factory="com.zaxxer.hikari.HikariJNDIFactory" idleTimeout="60000" jdbcUrl="jdbc:oracle:thin:@127.0.0.1:1521:orcl" leakDetectionThreshold="300000" maximumPoolSize="2000" minimumIdle="100" name="jdbc/oracle/msi" password="password" type="javax.sql.DataSource" username="USERNAME"/>

We are debugging an issue with a new Tomcat instance without deploying application(webapp is empty), there are 500 sessions opened though the minimumIdle is set to 100 only. Even after the idleTimeout="60000" the sessions remain the same, 500. Due to these session being consumed but HikariCP alone we are limited by the remaining sessions configured and our activities are failing.

When the minimumIdle is set to 100 why should it open session more than 100.

chakrim99 commented 4 years ago

We have tried with minimumIdle="10" and found the there are 50 sessions created. This would mean that HikariCP creates 5 times the minimumIdle.

lfbayer commented 4 years ago

Minimum means that HikariCP will try to ensure that there are "at least" that many connections. It is not a maximum.

So if the pool size starts at 10, and you take all 10 of them, hikari will automatically create 10 more to ensure that there are 10 more idle connections. This results in 20 connections total.

Unless you have a database server that has 1000 cores, it is very unlikely that you really want a maximumPoolSize of 2000.

I recommend these resources:

brettwooldridge commented 4 years ago

Additionally, it sounds to me like 5 pool instances are being created. If you enable debug logging this should be easy to verify.