Karaf DBCP2 Connection Pool

202 Views Asked by At

We have a 2 node setup in production where our bundles are running in karaf and using the DataSource service with DBCP2 connection pooling which is created in karaf as well as few bundles have their own connection pool being formed using DBCP. We are using Integrated Authentication (Java Kerberos) for connecting to SQL Server database. The user for both nodes and all the bundles is the same. We have configured a maxTotal of 50 for the pool on each node and for the bundles with connection pool maxActive is 10. But we are seeing around 25,000 connections to the database. Both nodes seem to have formed around 12,000 connections to the database and we have verified this both on database and through netstat on server. All these connections are sleeping and AWAITING COMMAND but their last batch time gets updated. I have the below questions.

  1. How does the connection pool determine if a particular connection belongs to its connection pool or another connection pool? Because the user for Java Kerberos on both nodes and all the connection pools is the same.
  2. Why are the connections increasing drastically? Based on out calculations the maximum connections from one node should be 220.
  3. We have multiSubnetFailover=true set in the JDBC connection string. Can this cause the connection pool to initialize multiple times?
  4. We sometimes get an issue with Kerberos Authentication and bundle needs to be restarted in this case. Can this cause the connection pool to try to initialize multiple times?

Below is the DataSource configuration in karaf.

osgi.jdbc.driver.name=mssql
pool=dbcp2
url=jdbc:sqlserver//<IP>:<Port>;multiSubnetFailover=true;databaseName=Temp_Db;integratedSecurity=true;authenticationScheme=JavaKerberos;socketTimeout=30000;queryTimeout=30
jdbc.pool.maxTotal=50
jdbc.pool.minIdle=5
jdbc.pool.maxIdle=10
jdbc.pool.maxWaitMillis=10000
jdbc.pool.timeBetweenEvictionRunMillis=5000
jdbc.pool.minEvicatbleIdleTimeMillis=1800000
jdbc.factory.validationQuery=SELECT 1
jdbc.pool.testWhileIdle=true
jdbc.pool.testOnCreate=true
jdbc.pool.testOnReturn=true
jdbc.pool.testOnBorrow=false 

Can anyone shed some light as we are not able to determine why so many connections are being created.

0

There are 0 best solutions below