Open pme123 opened 5 years ago
It looks like you have a single application with greater than 55 connection pools. Is that accurate? Why does one application connect to so many databases? How many connections is each pool allowed to have?
You mentioned you are using Play's default config settings for HikariCP. By default, it will initialize each pool you have with 10 database connections. So it needs to teardown and establish 10 connections per pool on every restart.
Try setting minimumIdle
to 1 (in development mode) which will only create a single connection per datasource and scale up as needed lazily.
Thanks with your input we know could get closer to the problem.
We have indeed lots of datasources, as the application serves different customers (tenants) and each of them can have a number of databases.
The problem are now datasources where the database is not reachable (during development). So we configured it, that the application also starts when the database is not reachable (initializationFailTimeout = -1
).
So there are 2 problems when shutting down:
So concrete the question is now can we influence these properties or do we need another configuration for development?
Instead of having them ignore failure to initialize can you make those datasources load lazily? That way it will only try to connect to the database the first time you access it.
That seems to work, I have some checks to do, the only thing at the moment is this error in the log file:
2019-11-12 17:48:50,969 [info] application - Creating Pool for datasource 'mydatabase'
2019-11-12 17:48:50,969 [error] c.z.h.HikariConfig - HikariPool-96 - dataSource or dataSourceClassName or jdbcUrl is required.
This happens when shutting down - what is a bit odd.
But no time lost for that.
Environment
I use the Play Default configuration for the Pools: https://www.playframework.com/documentation/2.7.x/SettingsJDBC#Reference
I have multiple Datasources when restarting during development the shutdown of some Pools take about 10 seconds. Most of them shutdown immediately.
It makes development a pain.
Is there a way to speed this up? For example share the pools between datasources.
I created also a Stackoverflow question: https://stackoverflow.com/questions/58639422/play-restart-on-code-change-takes-long-to-shutdown-and-starting-the-hikary-pool