Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HikariCP poolName not read from config #1326

Closed
rickynils opened this issue Oct 19, 2015 · 2 comments
Closed

HikariCP poolName not read from config #1326

rickynils opened this issue Oct 19, 2015 · 2 comments

Comments

@rickynils
Copy link

In HikariCPJdbcDataSource.forConfig, the pool name is not read from the config value (poolName, as documented on the HikariCP wiki), but instead picked up from the name argument (see https://github.com/slick/slick/blob/master/slick-hikaricp/src/main/scala/slick/jdbc/hikaricp/HikariCPJdbcDataSource.scala#L47).

Furthermore, the name argument is actually the path argument of the JdbcBackend.forConfig call (see https://github.com/slick/slick/blob/master/slick/src/main/scala/slick/jdbc/JdbcBackend.scala#L268), which is confusing since you get an empty pool name if you use a top-level config.

Is there any reasoning why the pool name is set like this and not simply picked up from the config?

@balagez
Copy link
Contributor

balagez commented Feb 11, 2016

This is actually a rather serious and annoying issue for play-slick users which manages Slick configuration itself so if poolName is not read from configuration there's no way for end users to set the pool name and all pools are created with the same db pool name. And since MBeans are looked up by poolName, without being able to configure the pool name it's impossible to monitor HikariCP connection pools if there are more than one in an application.

Example play-slick configuration based on the Play framework documentation:

slick.dbs.read.driver = "slick.driver.MySQLDriver$"
slick.dbs.read.db.driver = "com.mysql.jdbc.Driver"
slick.dbs.read.db.url = "jdbc:mysql://localhost:3306/dbname"
slick.dbs.read.db.poolName = "read"
slick.dbs.read.db.registerMbeans = true

slick.dbs.write.driver = "slick.driver.MySQLDriver$"
slick.dbs.read.db.driver = "com.mysql.jdbc.Driver"
slick.dbs.read.db.url = "jdbc:mysql://localhost:3306/dbname"
slick.dbs.read.db.poolName = "write"
slick.dbs.read.db.registerMbeans = true

And relevant parts of the HikariCP debug log:

2016-02-10 18:51:03,846 [DEBUG] com.zaxxer.hikari.HikariConfig - HikariCP pool db configuration:
...
2016-02-10 18:51:03,859 [DEBUG] com.zaxxer.hikari.HikariConfig - poolName........................db
2016-02-10 18:51:03,859 [DEBUG] com.zaxxer.hikari.HikariConfig - readOnly........................false
2016-02-10 18:51:03,859 [DEBUG] com.zaxxer.hikari.HikariConfig - registerMbeans..................true
...
2016-02-10 18:51:03,862 [INFO] com.zaxxer.hikari.HikariDataSource - HikariCP pool db is starting.
2016-02-10 18:51:03,912 [DEBUG] com.zaxxer.hikari.HikariConfig - HikariCP pool db configuration:
...
2016-02-10 18:51:03,921 [DEBUG] com.zaxxer.hikari.HikariConfig - poolName........................db
2016-02-10 18:51:03,921 [DEBUG] com.zaxxer.hikari.HikariConfig - readOnly........................false
2016-02-10 18:51:03,921 [DEBUG] com.zaxxer.hikari.HikariConfig - registerMbeans..................true
...
2016-02-10 18:51:03,922 [INFO] com.zaxxer.hikari.HikariDataSource - HikariCP pool db is starting.
2016-02-10 18:51:03,923 [ERROR] com.zaxxer.hikari.pool.HikariMBeanElf - You cannot use the same pool name for separate pool instances.

@balagez
Copy link
Contributor

balagez commented Feb 11, 2016

I think the commit 4569c52 didn't take into consideration that JMX and logging actually relies on configurable pool names.

I found no workaround for this issue because the pool is created and MBeans are registered in the pool constructor the same time the datasource is created and HikariCP provides no way to access the pool instance and register MBeans manually after the datasource is created. So having manually configurable pool names is a requirement for JMX monitoring.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants