I'm using hikari pool connection through play framework and mariadb client and since I've updated them (play 2.6.5 -> 2.6.6 and mariadb 2.1.1 -> 2.1.2 but not sure it's related) regularly I've got the following error:
HikariPool-1 - Failed to validate connection org.mariadb.jdbc.MariaDbConnection@31124a47 (Connection.setNetworkTimeout cannot be called on a closed connection)
at com.zaxxer.hikari.pool.PoolBase.isConnectionAlive(PoolBase.java:184)
at com.zaxxer.hikari.pool.HikariPool.getConnection(HikariPool.java:172)
at com.zaxxer.hikari.pool.HikariPool.getConnection(HikariPool.java:146)
at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:85)
at play.api.db.DefaultDatabase.getConnection(Databases.scala:142)
at play.api.db.DefaultDatabase.withConnection(Databases.scala:152)
at play.api.db.DefaultDatabase.withConnection(Databases.scala:148)
I've found a related issue here and tried to change the idleTimeout and maxLifetime to 2 and 5 minutes but the error still happened.
I'm using HikariCP 2.7.1, play 2.6.6 and mariadb-java-client 2.1.2
Although you write that you had no success solving this issue by changing the maxLifetime
value, I wanted to note that it actually worked for me. Putting its value to 590000
has removed the warnings from my log file.
The maxLifetime
(in milliseconds) value of your client should be less than the wait_timeout
(in seconds) value of your MySQL instance. This way the client will always terminate the connection before the database tries to. The other way around, the client will try to act upon a closed connection and you will get the above mentioned warnings in your log file.
To see the wait_timeout
value of your MySQL instance, you can use the following query:
SHOW VARIABLES like '%timeout%';
The default maxLifetime
value for MariaDB should be 28800
, but I noticed that 600
can be in place because of MySQL config files being loaded.
I should note that I have no other explicit hikari configuration in place except for a maximum-pool-size
of 50
.
I got the inspiration from: https://github.com/brettwooldridge/HikariCP/issues/856 by the way. Other very useful resources are: https://github.com/brettwooldridge/HikariCP#configuration-knobs-baby and https://mariadb.com/kb/en/library/server-system-variables/#wait_timeout
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With